Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Chrome pulling old JS file?

I've been having a crazy annoying problem for a few weeks that I can't seem to solve. Occasionally when I update the Javascript or CSS files for my site hosted on Siteground, Chrome will refuse to recognize them. Other browsers will pull the new files immediately if I empty the cache and refresh, Chrome will not.

I have:

  1. Verified through cPanel file manager that the correct files are uploaded to my server.
  2. Repeatedly emptied Chrome's cache.
  3. Repeatedly used devtools "hard reload" and "empty cache and hard reload".
  4. Repeatedly quit and reopened Chrome.
  5. Completely turned off Chrome's cache through devtools.

Maddeningly enough, the problem seems to solve itself when I come back to it a few hours later. What am I missing here that is keeping Chrome from reading the new files?

like image 395
Dylan Stark Avatar asked Feb 12 '17 21:02

Dylan Stark


2 Answers

Had this problem as well, going into developer tools solved the problem.

  1. open developer tools
  2. click on the network tab
  3. check the disable cache option, then uncheck it.

enter image description here

after doing this it then used the current version of my javascript file.

like image 50
Matthew Webster Avatar answered Oct 18 '22 15:10

Matthew Webster


Sometimes the server itself is caching the responses for certain user agents (which distinguish what kind of browser you're using to the server), which may explain your issue.

I suggest trying to change your UA (user agent) through devtools to what you currently have in firefox/safari for example to see if the problem persists.

That's just one of the ways that the server may cache responses for certain browsers, as it may also change from other small implementation differences.

Check through your server's settings to see if something is being server-cached, or if the server is adding additional caching information through localStorage and similar, and then try to change those settings or the pieces of code that rely on client storages that aren't considered cache.

like image 35
towc Avatar answered Oct 18 '22 13:10

towc