Chrome - Disable cache for localhost only?

Google ChromeWebBrowser Cache

Google Chrome Problem Overview


I'm using localhost for development; and I'm directly including jquery from CDN.

It seems that pressing the "Ctrl + R" would force the page to reload, including re-downloading the jquery from CDN.

I want to ask if it's possible that.. when I refresh, I keep the cache of the jquery from CDN, but clear the cache of my localhost?

NOTE: I know that one thing I can do is to host jquery file locally; I'm just asking to see if there's a way to bypass that.

Google Chrome Solutions


Solution 1 - Google Chrome

You can certainly prevent all your file from hitting the cache, but this is an all-or-nothing setting. You can't decide which files get cleared from the cache and which files stay in the cache.

During development, since you are using Chrome, I'd recommend to enable the setting for "Disable cache (while DevTools is open)":

Disable cache (while DevTools is open)

If you are like me, cache will be disabled every time you have the DevTools panel opened.

Another thing you can do is to instruct your server to bypass cache altogether for all your resources. Since jQuery is coming from a CDN, this no-cache setting won't apply for it. To disable cache for resources you can include the following response header:

Cache-Control:no-cache, no-store

Solution 2 - Google Chrome

In the browser, use this to refresh the page: Ctrl+Shift+R

this will ignore the cache (whereas Ctrl+r will use the cache).

yw :)

Solution 3 - Google Chrome

If you are using Apache you can disable cache on your server (localhost) by placing .htaccess file into your htdocs directory (or directory which you want to disable the cache for) with following content:

FileETag None
<ifModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</ifModule>

Solution 4 - Google Chrome

Press Ctrl+Shift+i to open developer tools, then go to network tab, and click on Disable cache

Solution 5 - Google Chrome

You can also hold down the refresh button and a menu with three options pops up:

Empty cache with Chrome

Solution 6 - Google Chrome

Method 1 (My fav)

I use this chrome extension. Note u will have to go into the extension options first and add the URL of the site you want to disable cache on.

Extension Link - https://chrome.google.com/webstore/detail/no-cache/ogbfmfambmmhfdpfokohebghmcdbodbh

Method 2

You can press Ctrl+Shift+R for a hard reload which will reload without cache.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionsongyyView Question on Stackoverflow
Solution 1 - Google ChromesvpinoView Answer on Stackoverflow
Solution 2 - Google Chromeuser5047085View Answer on Stackoverflow
Solution 3 - Google ChromeJuraj.LorincView Answer on Stackoverflow
Solution 4 - Google ChromeMustapha-BelkacimView Answer on Stackoverflow
Solution 5 - Google ChromeDavi MelloView Answer on Stackoverflow
Solution 6 - Google ChromeNaresh BishtView Answer on Stackoverflow