更新后刷新CSS样式表? [英] Refreshing CSS style sheet after changes?

查看:199
本文介绍了更新后刷新CSS样式表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能存在重复:

强制刷新缓存数据

Possible Duplicate:
Force refresh of cached data

最佳做法是更新css样式表后,一个网站经历视觉变化?

Whats the best practice for updating the css style sheet after a website goes through visual changes?

我最近更新了我的网页与新的图像和更新的CSS。当我的朋友浏览这个网站时,他的浏览器出于某种原因而在之前的CSS中出现了新图片。他之前曾访问该网站。根据我的理解,样式表没有被刷新,但是他的图像在第一次启动时导致图像显示不正确。在刷新页面后,它更新了CSS并且看起来没问题。

I recently updated my webpage with new images and updated the css. When my friend viewed the site his browser had the previous css rending with new images for some reason. He has visited the site before. From my understanding the style sheet was not refreshed but they images changed on his first launch of the site causing it to appear incorrectly. After he refreshed the page it updated the css and looked alright though.

在重大更改之后,是否需要更改css的名称以强制新样式表为下载?或者是否有办法让浏览器执行强制重新加载样式表?

Do I need to change the name of the css after major changes to force the new style sheet to be downloaded? Or is there a way to cause the browser to perform a mandatory reload of the style sheet?

推荐答案

他有以前的版本,因为它被缓存。在他的最后,他可以通过使用 cntrl + f5 (在chrome上)或他的强制浏览器等效。或者只是清空他的缓存。

He has the previous version because it is cached. On his end, he can "force" a fresh CSS file by using cntrl + f5 (on chrome) or his browsers equivalent. Or merely empty his cache.

对于你来说,你可以做的是改变样式表的名字。你可以通过在样式表href中添加一个?= x 来实现。它使得浏览器认为它是一个新版本,但实际上只是旧版本。

For you, what you can do is change the name of the stylesheet. You could do this by adding a ?=x to the stylesheet href. It makes the browser think it is a new version, but is infact just the old version.

如果您不希望文件再次被缓存(我不推荐)你可以给?= 添加一个时间戳,但是我不建议这样做。

If you never want the file to be cached again (which I don't recommend) you could add a timestamp to the ?=, but again, I don't recommend that

这篇关于更新后刷新CSS样式表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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