Html Chrome 未清除缓存

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41227767/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 14:08:41  来源:igfitidea点击:

Chrome is not clearing cache

htmlcssgoogle-chromecaching

提问by AndyPet74

I am working on a new site and whenever I change CSS settings chrome will not accept those changes unless I close out of chrome completely with Task manager and relaunch it. I have a tried quite a few things. Below is a list of things I've tried:

我正在一个新站点上工作,每当我更改 CSS 设置时,chrome 都不会接受这些更改,除非我使用任务管理器完全关闭 chrome 并重新启动它。我尝试了很多东西。以下是我尝试过的事情的列表:

  • Versioning the CSS file (I am using a PHP date stamp at the end of the CSS file
  • Enabling "Clear Cache while developer window is open" in the Developer console
  • Using Ctrl + F5 to clear cache on refresh
  • Going to Application and Clear Storage in the developer Console
  • Clearing Cache folder in local AppData
  • Deleting CSS file from stie, refreshing, and readding file.
  • Incognito mode
  • Adding Launch options to chrome shortcut --disk-cache-dir=null
  • Adding Browser Plugins to delete cache.
  • 版本化 CSS 文件(我在 CSS 文件末尾使用 PHP 日期戳
  • 在开发者控制台中启用“开发者窗口打开时清除缓存”
  • 使用 Ctrl + F5 在刷新时清除缓存
  • 在开发者控制台中转到应用程序和清除存储
  • 清除本地 AppData 中的缓存文件夹
  • 从 stie 中删除 CSS 文件,刷新和读取文件。
  • 隐身模式
  • 将启动选项添加到 chrome 快捷方式 --disk-cache-dir=null
  • 添加浏览器插件以删除缓存。

Anyone have any ideas how to help? It is extremely annoying and inefficient to close chrome every time I want to check a CSS change. Another annoyance is that I am trying to listen to music in the browser so if I close chrome I have to go back and get my music playing again and it's just as of now extremely annoying and way more time consuming than I want.

任何人有任何想法如何提供帮助?每次我想检查 CSS 更改时都关闭 chrome 非常烦人且效率低下。另一个烦恼是我正在尝试在浏览器中听音乐,所以如果我关闭 chrome,我必须返回并再次播放我的音乐,就像现在一样非常烦人,而且比我想要的更耗时。

I've tried looking at other articles online about cache busting and other articles on Stack Overflow but I've tried to do most of what they suggest and I haven't seen any positive outcome yet. Most articles say to add some sort of random string or version on the end of the CSS file as a GET request but that isn't working though I know that has worked for me in the past.

我曾尝试在网上查看有关缓存破坏的其他文章和有关 Stack Overflow 的其他文章,但我已尝试执行他们建议的大部分内容,但我还没有看到任何积极的结果。大多数文章都说在 CSS 文件的末尾添加某种随机字符串或版本作为 GET 请求,但这不起作用,尽管我知道这在过去对我有用。

采纳答案by AndyPet74

Development server was running various caching tools though they should have been turned off. After disabling them chrome started to work better and most of the time CTRL+F5 did the trick.

开发服务器正在运行各种缓存工具,尽管它们应该被关闭。禁用它们后,chrome 开始工作得更好,大部分时间 CTRL+F5 都可以解决问题。

回答by Pizza lord

pres f12 > f1 > network > disable cache (while DevTools is open). This should solve your problem

按 f12 > f1 > 网络 > 禁用缓存(在 DevTools 打开时)。这应该可以解决您的问题

回答by Luis H Cabrejo

"clearing cache"is not as easy as it should be. Instead of clearing cache on my browsers, I realized that "touching" the server files cached will actually change the date and time of the source file cached on the server (Tested on Edge, Chrome and Firefox) and most browsers will automatically download the most current fresh copy of whats on your server (code, graphics any multimedia too). I suggest you just copy the most current scripts on the server and "do the touch thing"solution before your program runs, so it will change the date of all your problem files to a most current date and time, then it downloads a fresh copy to your browser:

“清除缓存”并不像它应该的那么容易。我没有清除浏览器上的缓存,而是意识到“触摸”缓存的服务器文件实际上会更改服务器上缓存的源文件的日期和时间(在 Edge、Chrome 和 Firefox 上测试)并且大多数浏览器会自动下载最多的您服务器上最新内容的最新副本(代码、图形以及任何多媒体)。我建议您在程序运行之前复制服务器上最新的脚本并“做触摸事情”解决方案,这样它就会将所有问题文件的日期更改为最新的日期和时间,然后下载一个新的副本到您的浏览器:

  <?php
    touch('/www/sample/file1.css');
    touch('/www/sample/file2.css');
    touch('/www/sample/file2.css');
   ?>

then ... the rest of your program...

然后......你程序的其余部分......

It took me some time to resolve this issue (as many browsers act differently to different commands, but they all check time of files and compare to your downloaded copy in your browser, if different date and time, will do the refresh), If you can't go the supposed right way, there is always another usable and better solution to it. Best Regards and happy camping. By the way touch(); or alternatives work in many programming languages inclusive in javascript bash sh php and you can include or call them in html.

我花了一些时间来解决这个问题(因为许多浏览器对不同命令的行为不同,但它们都检查文件的时间并与浏览器中下载的副本进行比较,如果不同的日期和时间,将进行刷新),如果您不能走正确的道路,总有另一种可用且更好的解决方案。最好的问候和快乐的露营。顺便说一下 touch(); 或替代方案适用于许多编程语言,包括 javascript bash sh php,您可以在 html 中包含或调用它们。

回答by Stormhashe

I used to have the same problem, and I believe it's a (pretty annoying) bug with chrome. You can use the CSS Reloader Chrome Extensionto solve it. Not ideal, but better

我曾经遇到过同样的问题,我相信这是 chrome 的一个(非常烦人的)错误。您可以使用CSS Reloader Chrome Extension来解决它。不理想,但更好

回答by JohnH

If you are trying out new CSS updates, I suggest using Chrome's "Inspect" function to dynamically update CSS settings and observe the results interactively. This may save some time during update cycles as compared to manual edits alone.

如果您正在尝试新的 CSS 更新,我建议使用 Chrome 的“检查”功能来动态更新 CSS 设置并以交互方式观察结果。与单独手动编辑相比,这可以在更新周期中节省一些时间。

Another option to try is to define "cache-control" meta tags in your head section. For development/testing, you may want to have no caching. For a real website, you may want to have a shorter age limit. Refer to the following SO Q&A.

另一个尝试的选择是在你的头部部分定义“缓存控制”元标记。对于开发/测试,您可能不希望缓存。对于真正的网站,您可能希望设置更短的年龄限制。请参阅以下 SO Q&A。

Using meta tags to turn of caching in all browsers?

使用元标记在所有浏览器中关闭缓存?