34

I've got a web service that, like most others, uses js and css files. I use the old trick of appending a version number to the js and css file like; ?v=123 and that gets changed every time we update the service on production.

Now, this works fine on all browsers, except for Chrome. Chrome seems to prefer it's cached version over getting the new one and therefor seems to ignore the appended variable. In some cases, forcing it to refresh cache (cmd+r / ctrl+f5) wasn't enough so I had to go into options and clear out the cache for it to load up the new content.

Has anyone experienced this issue with Chrome? And if so, what was the resolution to the problem?

Magnus
  • 1,174
  • 2
  • 11
  • 21

3 Answers3

14

Chrome should certainly treat requests with varying query strings as different requests; a cached result for style.css?v=123 should never be used for style.css?v=124. If you're seeing different behavior, please file a bug at http://new.crbug.com/ and post the bug ID here.

That said, I'd first check to see whether the page was cached longer than you expected. If a new version of the page itself wasn't downloaded, then it would still be requesting ?v=123 as the HTML wouldn't have changed. If you're sending long-lived cache headers with the page, it's certainly possible that Chrome is caching it more aggressively than you expected. If that's the behavior you're seeing, please star http://crbug.com/8742 for updates.

Mike West
  • 5,097
  • 25
  • 26
  • Indeed. Check the source of the loaded html page (view source), see which resources have been requested with the chrome developer toolbar. I doubt it's a chrome bug, although aggressive caching might be a nasty 'feature'. – ivy Jul 18 '11 at 08:20
  • Fantastic answer Mike! It wouldn't surprise me the headers sent back for the page itself might be requesting longer cache then we'd want. I don't remember looking into that, so that's the first thing I'll do. Thanks again! – Magnus Jul 19 '11 at 04:26
  • My issue was that we *weren't setting* the expires/cache-control header. Definitely worth checking that these are set before trying something more drastic. – FuriousFolder Sep 09 '15 at 15:32
5

I had also same experience

You can user Ctrl + Shift + R for cache free browsing in both Chrome + Mozilla.

Mitesh Anand
  • 133
  • 1
  • 8
1

I have had this experience as well.

I run a membership site which displays content such as "You must be logged in as a Gold member in order to see this content" if they are not logged in or are trying to view content not allowed by their membership level. But even if the user is logged in, the user would still see "You need to log in", due to Google Chrome's aggressive caching. In Firefox, however, it works fine as I test logging in and out of all 5 levels of membership - each displaying the proper content.

While Chrome's caching problem can be solved by clearing the cache every time the user logs in and out, it would be really annoying to take that approach.

Peter O.
  • 32,158
  • 14
  • 82
  • 96