JavaScript file not updating no matter what I do

Viewed 148219

I have an external JavaScript file and whether in FireFox or Chrome, whether all browsing data is cleared, it will NOT update no matter what. I believe something happened when I made a backup of my file, which I simply added "_thedate" to the end of the name. Then Save As back to the original name.

Now I cannot seem to get rid of the old JS no matter what unless I change the name of the file, which I really don't want to do, or add the script to the PHP page, which crowds it.

Anyone know the solution to this?

15 Answers

I had this problem and solved in Chrome by just disabling Cache: - Click F12; - Go at Network tab; - Click on "Disable Cache".

In both Firefox and Chrome, that is really annoying, but because of their default settings which can be changed the following way and then they work. I tried in Chrome and Firefox both with same order of steps.

  1. Press F12 (Open Inspector)
  2. Click Network, and then click Disable Cache
  3. Now click Clear icon. In Firefox, it shows as a trash bin icon on left corner, in Chrome it is the second left icon, in between 'stop recording' and 'Filter'.
  4. Now press F5 or refresh the page

They do update the resources with their fresh copy as they re-download them.

1.Clear browser cache in browser developer tools 2.Under Network tab – select Disable cache option 3.Restarted browser 4.Force reload Js file command+shift+R in mac   Make sure the fresh war is deployed properly on the Server side

I was going insane trying to get my js files to refresh and I tried everything. Then I did a header check and remembered I was using Cloudflare!

In Cloudflare you can use dev mode to disable proxy.

Don't forget to check any errors in webpack compilation. Sometimes the application.js in app/javascript/packs/ doesn't reload due to webpack compilation error.

When I run into this issue I try this sequence of steps:

  1. Hard refresh the page.

  2. Clear cache + cookies.

  3. Add a static version to my script.

    src="my-script-name.js?v=1"

  4. If the above does not help, add a dynamic version to my script:

    src="my-script-name.js?v=" + Date.now() + Math.random()

Related