techarch / jquery-viewloader

Allows dynamic loading of HTML views (fragments)
6 stars 3 forks source link

IE10 + caching #2

Open temp3l opened 11 years ago

temp3l commented 11 years ago

Hi! I am using knockoutjs + viewLoaderPlugin + jquery Mobile and experienced a strange problem today:

In my debug-app I am using your viewLoader plugin alot! ( >15 templates).

In Internet Explorer 10 and only in IE10! (ie8-9 work fine):

Some of my templates won't be fetched! Sometimes it fetches 10-15 templates sometimes some more. Clearing and filling the cache affects the problem! if some templates were cached before, it almost always works fine

I think the "max. simultanious downloads of ressources" is somehow limited in IE10.

This code shows that only a couple of templates are fetched! the afterEachTemplate function is not called when the error occurs! - But "success" gets called!

$(document).viewloader({ afterEachTemplate: function (templateId) { console.log( $("#"+templateId).html().length ) }, success: function (successfulResolution) { console.log("done") } }, })

this probably isn't a viewLoader bug, but a limitation of IE. but I think the success function should not get called.

THX to techarch for the GREAT tutorials on Knockoutjs !!!!!!! Inspired me a lot!!!

stephan

techarch commented 7 years ago

Thanks for the feedback Stephan! I think you just need to add an error setting (and function) in the viewloader parameter. That error function will be called if any error occurs during loading.

Ironically I run into a caching issue today and realized I needed to ensure that the browser cache gets invalidated when template version changes. I had used the technique of adding a querystring parameter with the current versionId in many web apps I am involved in. And this morning I finally incorporated the enhancement. I guess it is never too late. :-) FYI this library is used in production in several complex applications and has faired really well over the years.