views:

186

answers:

3

We've identified that full browser caches are the cause of a problem on our extranet. It only affects a small number of our users, but we'd like to alert them to the problem and give them some guidance on how to fix the problem for themselves.

We'd like to use a similar system to the one which GMail uses. When it detects that your browser's cache is full is not behaving as it should, it shows a warning message telling users that their cache is full and that it may cause problems with GMail, along with a link to a Gmail Help page on clearing your browser's cache.

Does anyone know if there any resources out there, or examples of how to use JavaScript to detect that the browser's cache is full behaving badly?

Thanks.


Clarification: What we're actually trying to detect, I suppose, is not whether or not the cache is full, but rather whether a script, which we have configured server-side to be stored in the cache, is being re-requested from the server - in such a way that the browser is behaving strangely, or as if its cache is not behaving as it should.


Further Clarification: Thank you all for the updates on caching. Our scripts are being sent with the correct headers, and we're only seeing this problem in IE6 and IE7 - Mozilla and WebKit browsers seem to be unaffected - but I'm still not sure on how exactly we'd go about using JavaScript and/or XmlHttpRequest to check to see whether or not an object was retrieved from the cache, thus letting us check whether the cache is behaving badly.

+4  A: 
scunliffe
Given that, would you suggest waiting until the page had finished loading and then firing off an asynchronous request for the (headers of the) same script that we're loading in the `<head>` section of the page, then checking to see whether it was loaded from the cache or from the server?
abitgone
A: 

This will probably not work as is. But its just an idea:

var img = new Image();
(new Image).src = "imageWithFarFutures.png";
window.onload = function(){
    document.getElementById("someIframe").src = "imageWithFarFutures.png";
    // NOW if the server DOES get a FRESH request for "imageWithFarFutures.png"
    // wouldn't it mean that the browser has kicked it out of its cache?
};
David Murdoch
A: 

Consider sending a header to have your application never cache your content and to have it expire immediately.

Freebytes
Why? That's completely against what we're trying to do - we want this particular piece of content to cache.
abitgone