javascript - Image preload not working -


i wrote (well, copied) javascript image preload function , seems preload images when page loads, when page needs display images, there delay during apparently loads them again, defeating purpose of preloading. possible causes of behavior , fixes?

i tried failed create reproducible code guess cause of somewhere in complexities of whole project. here's image preload function i'm using:

function preload(sources) {   var images = [];   (i = 0, length = sources.length; < length; ++i) {     images[i] = new image();     images[i].src = sources[i];   } } 

i call on long array of images stored on our server when page loaded, , can see long list of "get" requests in console seem indicate it's indeed preloading images. later, when images displayed within dynamically generated content (using jquery if matters), there delay when loaded , see request in console, status "http/1.1 304 not modified". looks images being loaded again instead of using cached version. causing this?

i have ajax calls occurring after image preload, before image display, "cache: false" in them - possible cause? however, these ajax calls don't directly affect page content - used database info in turn affects page content.

by way, using firefox testing. read somewhere chrome @ time send requests see whether cached images had been modified supposedly not issue firefox.

turn off firebug , images not loaded twice. if have firebug turned on preloaded image not being cached.

you can verify behaviour proxy charles


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -