64

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

It seems that pressing the "Ctrl + R" would force the pace 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.

songyy
  • 3,881
  • 4
  • 36
  • 58
  • 6
    Use shift+F5 to refresh the page, it forces to clear cache.. If doesn't work try to press a few times. – Sercan Ozdemir May 20 '14 at 05:39
  • How about keeping the cache from remote server..? – songyy May 20 '14 at 05:44
  • 3
    i think he wants to KEEP it cached. Not cleared from cache. On really slow internet, waiting for CDN is annoying,but caching local files that you're working on is also annoying - so would be nice to have a mix. I've resorted to downloading the CDN file locally for now. – robert king Feb 02 '16 at 01:49

4 Answers4

61

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
svpino
  • 1,704
  • 16
  • 17
  • 15
    For the current version of chrome "61", this feature moved to the developer tool. To activate it you have to go to: More Tools > Developer tools > Network "tab" then click on Disable cache. Note that this work only when the Developer tool is open. – Oussama Bouthouri Sep 27 '17 at 10:19
23

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 :)

5

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>
Juraj.Lorinc
  • 455
  • 7
  • 22
3

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

Mustapha-Belkacim
  • 904
  • 1
  • 9
  • 14