简体   繁体   中英

Browser does not show changes in JavaScript. It keeps the old version

Im working with:

  • Chrome

  • Codegnitor (PHP)

  • XAMPP

  • CSS and JS

My problem is: When I do a small change in CSS or JS (any simple, trivial change), the browser does not show this change. Only when I rename the CSS or JS file it shows the change.

Its looks like the browser remembers the old version of CSS or JS and does not "go and look for the changes" when I reload the page in Chrome.

Any idea what is holding back the browser?

I've been searching for a question, but found only people whose browsers do not take jS into consideration at all.

But my browser does. It deos load JS, but not the changes that I make.

The funny thing is that a week ago I needed to rename CSS and JS file once or twice a day, but now I need to rename it when I make any change to see that change displayed in the browser.

So it is imposible to work.

Someone having the same issue?

PS I'm having the same issue with Mozilla nad IE. So I guess somthing could be wrong with my computer. Could it be one of those security programs. I've got one with FileZilla two weeks ago but I thought I've got rid of it. Maybe it is still making the mess in the background.

You can disable cache when developer tools is visible. Hit F12 and click the little gear at the bottom right. In "General" make sure that the first box "Disable cache (while DevTools is open)" is ticked and you're good to go

The CSS and js resources are probably cached by your browser.

When you change and reload to test, try reloading using Ctrl+R to refresh the cache in that reload. This should work with all browsers.

If you use MAC. press COMMAND+SHIFT+R to refresh!

Just in case other people come across this you can add a get variable to the file name like src="js/custom.js?version=1" then it will recheck if it doesnt know. You could have all the custom javascript and css files like this and with php use something like:

src="js/custom.js?version=<?php echo $version; ?>"

then justupdate $version in one place anytime you make a change. This will also guarantee users see the change as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM