Stop Chrome Caching My JS Files

I will make a change to my JS files but it won't really change in the browser, I have to rename the files every time so that it reloads it. Is there some sort of .htaccess command I can add or something to make it stop caching?

It is even caching my html pages hard core. I need to reopen my entire browser just to see changes. Could it possibly be a server problem?


Solution 1:

You can click the settings icon on top right corner ... | More Tools | Developer Tools | Network | Disable cache (while DevTools is open)

For windows, this is F12 or CTRL + SHIFT + I while on mac CMD + SHIFT + I opens up DevTools.

New path for Chrome Update Sept 2018:

Click settings icon on the top right corner ... | Settings | Preferences | Developer Tools | Network | Disable cache (while DevTools is open)

Solution 2:

A faster way to do this is by right clicking the refresh icon beside the address bar and choosing Empty Cache and Hard reload

Just make sure Chrome's dev tools is open. (Press F12) By the way... This trick only works on Chrome for Windows, Ubuntu, and Mac OS

Solution 3:

Hold Shift while clicking the reload button (F5).

This forces the web browser to ignore the cached content and pull a new copy of the web page into the browser. Shift + F5 guarantees that the latest website content will be loaded. However, depending on the page size, it is usually slower than only F5.

Solution 4:

add Something like script.js?a=[random Number] with the Random number generated by PHP.

Have you tried expire=0, the pragma "no-cache" and "cache-control=NO-CACHE"? (I dunno what they say about Scripts).