Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
780 views
in Technique[技术] by (71.8m points)

web - 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 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...