Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome - Disable cache for localhost only?

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.

like image 314
songyy Avatar asked May 20 '14 05:05

songyy


People also ask

How do I clear my localhost browser cache?

While in your browser, press Ctrl + Shift + Delete simultaneously on the keyboard to open the appropriate window. IMPORTANT: Be sure and close/quit the browser and restart it after clearing the cache and cookies. Click the Tools menu (three dotted lines in the upper-right corner). Select History.

Can you clear cache for just one site?

Here's how to clear the browser cache for just one web page: Open the webpage you want to clear the cache for, and go into Chrome Developer Tools. That's CMD+Option+I on a Mac, and CTRL+Shift+I or F12 on Windows, Linux, and Chromebooks. Click Empty Cache and Hard Reload in the list of options, and you're done.


1 Answers

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 
like image 197
svpino Avatar answered Oct 22 '22 03:10

svpino