Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome caching like a mad browser

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?

like image 503
Magnus Avatar asked Jul 04 '11 22:07

Magnus


People also ask

How do I stop Chrome from caching?

When you're in Google Chrome, click on View, then select Developer, then Developer Tools. Alternatively, you can right click on a page in Chrome, then click Inspect. Click on the Network tab, then check the box to Disable cache.

How do I force a browser to not cache?

But you can bypass the cache and force a complete refresh by using some simple hotkeys: Windows and Linux browsers: CTRL + F5. Apple Safari: SHIFT + Reload toolbar button. Chrome and Firefox for Mac: CMD + SHIFT + R.

What is caching in Chrome?

How cache & cookies work. Cookies are files created by sites you visit. They make your online experience easier by saving browsing data. The cache remembers parts of pages, like images, to help them open faster during your next visit.


2 Answers

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.

like image 184
Mike West Avatar answered Sep 19 '22 09:09

Mike West


I had also same experience

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

like image 28
Mitesh Anand Avatar answered Sep 20 '22 09:09

Mitesh Anand