views:

57

answers:

1

How can I find out if pictures on my page are loaded from browser's cache or from a remote server to which their <img src=.../> points to?

+1  A: 

If the remote server is not the same server as wehre the page is located, the short answer is: you don't.

If you REALLY needed this information, you would set up a proxy on your server to the remote image. Then you could track hits to the remote server image by way of the proxy. With proper cache settings (i.e. must-revalidate) you could check to see if each image request is going to be a fresh load, or one from the browser cache.

If it wasn't for the security policy of the browser, you might be able to do it via some VERY tricky AJAX.

If the page and remote server are on the same place, you could possibly get that information by storing a session of the user for every request (including images), and keep track of when the page and component images are loaded.

Of course, I could have completely misunderstood your question, and you want to see if YOUR browser is caching an image or not, in which case Firefox has an extension called LiveHTTPHeaders that will help. (ieHTTPHeaders for Internet Explorer). Conversely Firebug will do the same thing on its "net" tab. YSlow will give you oodles of cache information as well.

Jonathan Arkell