为网站开发禁用 Chrome 缓存 [英] Disabling Chrome cache for website development

查看:23
本文介绍了为网站开发禁用 Chrome 缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在修改网站的外观(CSS 修改),但由于烦人的持久缓存而无法在 Chrome 上看到结果.我试过 Shift+refresh 但它不起作用.

如何暂时禁用缓存或以某种方式刷新页面以查看更改?

解决方案

Chrome DevTools 可以禁用缓存.

  1. 右键单击并选择 Inspect Element 以打开 DevTools.或者使用以下.com/chromiumdev" rel="noreferrer">@ChromiumDev 表示,此设置仅在开发工具打开时有效.

    请注意,这将导致重新加载所有资源.如果您只想为某些资源禁用缓存,您可以 修改您的服务器与您的文件一起发送的 HTTP 标头.

    如果您不想使用禁用缓存复选框,长按刷新按钮打开DevTools将显示一个菜单,其中包含选项>Hard ReloadEmpty Cache and Hard Reload 应该有类似的效果.阅读两者之间的差异options 以知道选择哪个选项.可以使用以下快捷方式:

    • Command+Option+R 在 Mac 上
    • Control+Shift+R 在 Windows 或 Linux 上

    I am modifying a site's appearance (CSS modifications) but can't see the result on Chrome because of annoying persistent cache. I tried Shift+refresh but it doesn't work.

    How can I disable the cache temporarily or refresh the page in some way that I could see the changes?

    解决方案

    The Chrome DevTools can disable the cache.

    1. Right-click and choose Inspect Element to open the DevTools. Or use one of the following keyboard shortcuts:

    • F12
    • Control+Shift+i
    • Command+Shift+i

    1. Click Network in the toolbar to open the network pane.
    2. Check the Disable cache checkbox at the top.

    Keep in mind, as a tweet from @ChromiumDev stated, this setting is only active while the devtools are open.

    Note that this will result in all resources being reloaded. Should you desire to disable the cache only for some resources, you can modify the HTTP header that your server sends alongside your files.

    If you do not want to use the Disable cache checkbox, a long press on the refresh button with the DevTools open will show a menu with the options to Hard Reload or Empty Cache and Hard Reload which should have a similar effect. Read about the difference between the options to know which option to choose. The following shortcuts are available:

    • Command+Option+R on Mac
    • Control+Shift+R on Windows or Linux

    这篇关于为网站开发禁用 Chrome 缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆