Chrome - Disable cache for localhost only?

老子叫甜甜 提交于 2019-11-28 17:46:18

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

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

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

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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!