Detecting if a browser's cache is full

混江龙づ霸主 提交于 2019-12-03 14:55:46

The browser's cache will not cause problems if it is full... with a few minor notes.

  1. If the browser cache is full, the browser simply has to download fresh content vs. pulling it from its local cache. (e.g. is slower)
  2. If the browser cache contains invalid data (e.g. an old copy of a JavaScript file) then yes, you may encounter issues. (not because the cache is full, but because you didn't serve up a fresh file for the user (Google for: expires headers and how to alter the URL path to your files when you make script changes to ensure you "break" the cache))
  3. In Internet Explorer, when you push a download file (e.g. an Excel spreadsheet) to the user it must go into the cache to work (an IE bug) - I'm not sure if the file is bigger than the users' total cache, if that causes issues with the file being stored, and therefore loaded (Stackers pls feel free to confirm if this one way or another)

Update: Based on your clarification, you need to ensure that any script you send to the client is appropriately cached... which means:

  • Change the URL to your scripts when you want a new version to be downloaded (e.g.)
  • Once you are sure that the URL changes, you can send cache headers that tell the browser to cache the files for a very long time (e.g. your JS Library files (e.g. jQuery) likely don't change every hour, day, week or even month)

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?
};

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!