Way to get Chrome to always re-download styles and images on every visit to the page during development/testing?

℡╲_俬逩灬. 提交于 2019-12-10 03:29:14

问题


As brilliant as Firebug is, I would consider switching my JavaScript debugging to Chrome if I could figure out how to get it to always re-download styles and images on every visit to the page?

When I'm testing a page in Firefox, it always gets the latest version.

But in Chrome I often end up scratching my head over something that turns out to be a simple issue of the browser caching some earlier styles or images.

Is there a way to configure Chrome to cache less while you're developing?


回答1:


I often use private browsing mode for this - it prevents caching of the stylesheets or scripts.

EDIT:

Another really easy way to do this in Chrome now is to go into the Chrome Developer Tools, click the settings gear (bottom right), and then check "Disable cache." See https://stackoverflow.com/a/7000899/4570.




回答2:


A bit late to the party, but just for people who may pick up this page on a search, new versions of Chrome have a developers tools setting to disable the cache. Show developer tools (spanner->tools->developer tools) and on the bottom right is a tiny little gear. click that and a few settings appear in the developer tools window, one of which is to disable the browser cache. If you can't see it you may have to upgrade to a newer version of chrome.

Ian




回答3:


According to Chrome help pages, Ctrl+F5, Shift+F5, Ctrl+R and Shift+R should force refresh. I haven't had problems with javascript and css but refreshing frames is another story. The caching can also be on your web server. The server can obviously be configured to cache css and javascript files.




回答4:


Your best bet is to clear the cache between each load. With the latest version of Chrome, the hotkey is the same as firefox (on Mac, it's Shift-Command-Del). However, they haven't focused the "Clear Browsing Data" button, so you have to use your mouse to click that button -- which is a total PIA when compared to Firefox (Shift-Command-Del + Return), or Safari (Option-Command-E + Return).




回答5:


the 2.5 ways i do it are not "automatic" but they're very quick, and i don't have to remember to switch back from private browsing - a) install Mouse Gestures and use (this is a great extension anyways, but even more so now that I know about) Up, Down, Up - this is a cacheless reload. You can get it here

b) ctrl+shift+r is [supposed to be] a cacheless reload. Even the help pages admit this isn't perfect

c) the .5 is a kind of a hack - but if you are working with CSS files, open a new tab and type in the address to the CSS file itself - you can see what changes are there, as well as make sure that you've gotten the latest one by refreshing this file before your other file. a bit of a pain, i know, but always works.




回答6:


Not sure about your system but on this WinXP machine holding SHIFT while clicking refresh always forces a complete download.

That's what I do when doing CSS and image tweaks.




回答7:


That Chrome needs to have must-revalidate in the Cache-Control` header in order to re-check files to see if they need to be re-fetched the way that the other browsers do by default.

Recommend the following response header:

Cache-Control: must-validate

This tells Chrome to check with the server, and see if there is a newer file. IF there is a newer file, it will receive it in the response. If not, it will receive a 304 response, and the assurance that the one in the cache is up to date.

If you do NOT set this header, then in the absence of any other setting that invalidates the file, Chrome will never check with the server to see if there is a newer version.

Here is a blog post that discusses the issue further.



来源:https://stackoverflow.com/questions/4028427/way-to-get-chrome-to-always-re-download-styles-and-images-on-every-visit-to-the

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