Sometimes when I make small changes to a website, I notice that certain browsers are very stubborn about downloading the page again. Both F5 and CTRL-R are worthless and the only way to fix it is to go through the options and manually tell it to clear the cache. I've used PHP before to send a cache-flush header, but is there a simpler or better way?
How can I cause a browser to download a new copy of a web page when it thinks that its cached copy is still valid?
It depends on what's cached. If it's the main page then the only way to prevent caching is using the no cache HTTP header.
However keep in mind that JS and CSS files are also usually cached. One trick to invalidate them when they change used by many websites - including this - is appending a dummy number after the '?'. Everything after the '?' is ignored by the web server, but since the URL changes the browser always re-downloads it.
An example taken from this very page:
http://sstatic.net/webmasters/all.css?v=ac775b7bd951. The "ac775b7bd951" comes from mercurial, the versioning system used. You can do something similar with svn (example: all.css?revision=123).
F5 is refresh using the cache. Ctrl-F5 will ignore the cache. I'm not certain, but it sounds like Ctrl-R is equivalent to F5 rather than Ctrl-F5?
Yep that's right. Although I believe in Opera Ctrl+F5 reloads ALL the pages. Jul 13, 2010 at 12:23