Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome Refuses to Clear Javascript Cache (Even After Hard Reload and Manual Cache Clear)

Like the title says, Google Chrome refuses to load newer versions of a Javascript file.

I've tried:

  • Ctrl + F5
  • Dev Console > Network Tab > Disable Cache
  • Disable Cache, Then With Dev Console Still Open Right Click Refresh > Empty Cache and Hard Reload
  • Disable Cache, Then With Dev Console Still Open Ctrl + F5
  • Chrome Settings > Manually Delete All Cache From Beginning Of Time, Then Ctrl + F5

Basically everything listed here: Chrome WON'T clear cache... ctrl + F5 doesn't seem to work either

None of this worked. The sources panel still shows that the old Javascript file was being loaded. The absolutely mind-boggling thing is that when I right click the file in the sources panel and then select open in new tab, the updated file opens in a new tab, but then refreshing the page still brings up the old file in the sources panel of dev console.

The only thing that has gotten Chrome to work for me is to manually append ? and a random number at the end of the file name. That seems to force Chrome to actually load the new file. As of now, I've been using PHP to add a

<script type="text/javascript" src="file.js<?php echo '?' . rand(); ?>"></script>

in order to get anything to load correctly in Chrome, but this seems like a terrible solution.

My question is, How do I get Chrome to actually reload Javascript files from the server instead of the cache?

like image 341
mt_xing Avatar asked Jan 17 '18 17:01

mt_xing


People also ask

Why is my cache not clearing in Chrome?

Here are some ways you can try to fix your caching problem, in order of escalation: Try holding down the Shift key while pressing the Refresh button. Close your browser and re-open it (make sure you are NOT on the cached page) and delete your temporary Internet files (clear your cache).

Why does cache return after clearing?

You might notice that when you clear cache, it comes back eventually. This is normal; over time, apps will build up cache again based on your usage. Because cache is useful, you shouldn't worry when an app builds up cached files. Clearing cache shouldn't log you out of apps or cause any other major changes.

How do I stop Javascript caching in Chrome?

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. You can then close out of Developer Tools.


1 Answers

Have you tried completely wiping your cache ?

C:\Users\yourusername\AppData\Local\Google\Chrome\User Data\Default\Cache

like image 146
Ben Leonard Avatar answered Sep 17 '22 17:09

Ben Leonard