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

4

59

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?

Lotus answered 19/5, 2010 at 22:7 Comment(0)
P
43

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 they uses the browser rarely, it will be until the expiration - either by internal policy or by HTTP headers. If they 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.

Purl answered 19/5, 2010 at 22:16 Comment(5)
Browsers don't keep items in cache "indefinitely" when headers such as "Expires", "Cache-Control", or "Last-Modified" are present. Rather, browsers will set a specific expiration time for that content. Your answer implies this, but it should be explicitly stated.Ceratodus
@StephenOstermiller - thanks. I did meant it by "(i.e. until expiration)" but I hope it's clearer now.Purl
@StephenOstermiller Well, technically isn't he correct since if a user stops using a browser the cache is going to remain until the browser is used again? Correct me if I'm wrong. I mean, seems like a silly point to make except from a security standpoint there may be cached data recovered off a PC because it's still there as long as the browser isn't opened. Am I wrong?Opium
There could be cases a browser is no longer used and still has really old cache sitting around. However, the question is about whether browsers refetch files, not about inactive browsers.Ceratodus
@StephenOstermiller you seem to reiterate what you wrote 3 years ago. I tried to clarify it by "If he/she uses the browser rarely, it will be until the expiration - either by internal policy or by HTTP headers.". TBH I'm not sure how to clarify it further.Purl
R
4

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.

Requite answered 19/5, 2010 at 22:21 Comment(1)
Here's the link to last working copy from archive.org. Note that the document is ~8 years old (2008) which is quite ancient in browser behaviour terms. This question is still in the top 10 when you ask Google.Stalinabad
G
2

As the other answers have stated, it depends upon the browser settings. But note that having a file cached doesn't necessarily mean that changes are not fetched from your site. If configured to do so, the browser will send a request to the server, with details about the date of the cache file. The server than then respond with "ok, use your cache - it's the latest version" when there are no changes. This repsonse is small and quickly sent. If the server version has been updated, then the server will respond with the new version.

How often the browser sends a request to the server is browser-specific - they can be configured to check for updates each time, once an hour, once a day, never or anywhere in between. The server can also specify how often the browser should check for updates.

this is just a sketch - it is simplified and incomplete. For the complete details, see W3C - HTTP/1.1 Caching.

Giliane answered 19/5, 2010 at 22:32 Comment(0)
B
0

Depends on how long the server specifies. The server sends back parameters in response header. They can specify max-age (how long to cache the file before it expires in milliseconds) or an expiration date (date that the file will expire). If it has both, max-age will take priority.

Biquadratic answered 16/9, 2013 at 6:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.