How long are files usually kept in a browser's cache

How long are files usually kept in a browser's cache? I'm wondering about the general population - how long would I need to wait to be reasonable certain that most people's caches will refetch the file?


Solution 1:

It depends much on person, browser and settings.

Browsers usually reserve a certain amount of disk space, like 12 MiB, to this task. If a user stops using the browser it is indefinitely. If he/she uses the browser rarely, it will be until the expiration - either by internal policy or by HTTP headers. If he/she uses the browser heavily, it can be 12 minutes or even less.

I believe that it is hard to say 'in general' as I had a website on which 50% entries were from Firefox and 49% from Opera when IE at that point had over 75% market share. If the target audience of your site are users who use their browsers heavily, it can be very short. On the other hand if your site is only website visited it can be nearly never.

Solution 2:

Typically files will stay in the cache until space runs out. There is an article that describes some of the defaults for popular browsers: It's Time to Rethink the Default Cache Size of Web Browsers

As Maciej stated, it's also a matter of how much each person browses. Think of the user base that will be visiting your site into consideration, as well as how bandwidth-heavy your site is (if the average user downloads tons of content from your site, chances are they will fill their cache real fast).

If a cache refresh is needed, you can force the page to not cache files.