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?
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.
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.
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.
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.
© 2022 - 2024 — McMap. All rights reserved.