硬刷新网站设计 [英] Hard refresh website design
问题描述
我正在开发一个网站,但是每次进行小的更改时,我都必须执行一次硬刷新才能看到更改.
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.
我该怎么办?
推荐答案
您可以通过添加缓存控制元标记来强制页面不进行缓存:
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">
您还可以通过添加版本的get参数来阻止样式表的缓存:
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.
这篇关于硬刷新网站设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!