Is it possible Firebug may be incorrectly adding downloads to the Net tab when things may be loaded from the cache?
I have some code in a Javascript gallery which is meant to lazily download an image when the thumbnail is clicked and then display it once downloaded. It is meant to determine if it’s been downloaded already first (via an array with Boolean values), and if it has been downloaded before, simply display from cache.
I thought it was working fine for a while (because of the speed at which they would appear when clicked twice), but I recently looked into Firebug’s Net tab and it seems to be downloading the large image every time (and the total file size gets bigger with every click).
I’m not sure what I have done wrong as a bit of debugging has informed me the Boolean values are being updated correctly.
So my question is, could Firebug be incorrect (I doubt it), or is there any way I can force it to display from cache (I thought using the exact same path to the image for the image.src would do this)
This was my first venture into objects in Javascript so I’m not 100% confident about my code so please be kind!
The image appearing in the net tab in firebug does not mean it is downloaded from the server. Check the HTTP response code that firebug reports for the image – for me after one visit, it kept returning ‘304 – Not Modified’ which means it is being loaded from the cache.
You can avoid the extra HTTP request that checks if the cache is still fresh by sendingfar-future headers for components you want to cache hard. Bear in mind though, that in order to force the client to re-download a component that was cached this way you’ll have to change the filename.