I’ve tested “Who’s Online” with:
- Chrome - working OK after clearing the browser cache
- Firefox - working OK after clearing the browser cache
- Opera - working OK after clearing the browser cache
- Egde - worked first time
I’d recently accessed the forum using Chrome, Firefox and Opera which is why I had to clear their caches. I hadn’t used Edge to access the forum for some time so the cache would have been stale and therefore refreshed automatically.
4 hours is what Cloudflare suggests to browsers as a TTL (time-to-live) for the browser cache. It is only a suggestion. Browsers are free to choose how long they cache pages/page components for. Unfortunately, Safari is no longer available for Windows so I’ve no way to test it on my equipment and I can’t explain why it is retaining cached files for longer than is suggested, nor why Apple don’t provide a way to clear the cache. The Cloudflare cache was cleared of incorrectly minified files yesterday, so from that point it’s up to browsers to pick up the latest files, which should be at most after 4 hours. I don’t know of anything I can do to force browsers to refresh their caches. It seems odd that Safari has a >24 hour cache time though.
For general info for everyone…
There are (at least) two levels of caching taking place when you access the forum.
Cloudflare cache - The Cloudflare system grabs copies of files and for slow changing files, e.g. JavaScript and CSS, it keeps a copy in it’s ‘global’ cache to be provided when browsers access the forum. This speeds things up a little because you’re not relying on the network link directly to my server. For example, if a lot of people are accessing the forum much of the data will be sent from the very fast Cloudflare cache/network rather than relying on the direct link across the Internet to my forum (which does have a 1Gbps network connection and a very quick link to the Internet).
Browser cache - Your browser almost certainly (I think pretty much all browsers do caching) caches files downloaded from the server (actually what Cloudflare sends to you). It’s probably caching the same kind of files as Cloudflare do, e.g. JavaScript and CSS. If a file is present in your local cache then the browser can display it from disk rather than having to download it.
Obviously caching can save bandwidth and improve page display times, but there’s an obvious downside that if files do change then it will take some time for your display to change because you may be displaying from your local browser cache or the Cloudflare cache. There are various techniques used to avoid this, e.g. fast changing files often have some form of ‘cache-busting’ mechanism built in, e.g. they may be given a subtly different name each time you access them which makes both Cloudflare and your browser believe it’s a new file and always download it. Or the server can issue a “don’t cache this page” flag, although caches are free to ignore these flags but that would then make fast changing sites not work very well. The forum index page uses one of these techniques to make sure you always see the latest posts when you access it.
The Cloudflare and browser caches work automatically, each deciding when to try to get new data. However…
Your browser might decide it wants a new copy of a file, e.g. because it’s local cache timeout has triggered, or you’ve cleared the cache. If it requests the file again then it will just get what Cloudflare has in it’s cache. “You” can’t override Cloudflare. So if your browser cache is 1 hour and Cloudflare is 4 hours, then 3 out of 4 times your browser is going to dowload the same file until Cloudflare updates it’s own cache and sends you a new file (if there is one).
Cloudflare cache updates files after 4 hours (as I currently have it configured). However, I have the option to do a manual purge of the cache. At this point, Cloudflare will download every new file that’s been accessed directly from my server, to fill it’s own cache, and then send that file to browsers requesting it. If your browser doesn’t request the file then it won’t get the latest file. This is why to solve this recent problem I had to first purge the Cloudflare cache so that good versions of the files were available to be downloaded AND then you had to clear your browser caches so that your browser would request new copies of all files and therefore download the good files from Cloudflare.
I said there are ‘at least’ two levels of caching. Some ISPs also provide (or used to anyway) caches within their networks. If an ISP is serving a few million users in a country an ISP cache could save them bandwidth, e.g. if a million people all access news sites trying to find out what’s happening in a general election in the country, then if the ISP has the files locally they don’t need to download them from the new site at every access. This can make their own Internet connections faster. I had experience of one of these in the past and it wasn’t good. You can clear your browser cache, but if the ISP cache is doggedly holding onto a file that has been updated there’s nothing you can do to force a refresh.