Hard refresh website design

随声附和 提交于 2019-12-13 05:40:39

问题


I am developing a site, but every time I do a small change I have to perform a hard refresh in order to see the change.

The obvious question here is that a user probably will never do a hard refresh, and so he/she will not see the effects immediately. Plus, sometimes when I change the stylesheet, without hard refresh the site looks like a mess.

What can I do?


回答1:


You can force the page not to cache by adding cache control meta tags:

<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">

You can also prevent caching of your stylesheet by adding a version get parameter:

<link rel="stylesheet" href="mystyles.css?v=1" type="text/css" />

Increment the version number to force a new version to be loaded.




回答2:


So, the changes in your design (external stylesheets?) are not immediately showing?

This probably has to do with the browser cache. Your files are cached, which is a good thing. If you want to invalidate the cache, you might add a parameter to your external files, like this:

<link rel="stylesheet" type="text/css" href="http://sstatic.net/stackoverflow/all.css**?v=f023310c4326**">

The developers of this awesome piece of software know all about this.



来源:https://stackoverflow.com/questions/5522695/hard-refresh-website-design

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