6

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?

2 Answers 2

6

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).

2

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?

1
  • Yep that's right. Although I believe in Opera Ctrl+F5 reloads ALL the pages. Jul 13, 2010 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.