简体   繁体   English

强制清除浏览器缓存

[英]Force browser cache to clear

After deploying a new release of an ASP.NET website, is there a way to force clients' browsers to refresh cached items, especially for images, CSS, and Javascript files? 部署新版本的ASP.NET网站后,是否有一种方法可以强制客户端的浏览器刷新缓存的项目,尤其是图像,CSS和Javascript文件的缓存项目?

The problem is that I can't go around telling everybody that uses the site to hit CTRL + F5 . 问题是我无法告诉所有使用该站点的人按CTRL + F5 How can I force the browsers to do it? 如何强制浏览器执行此操作?

Nada, 纳达,

I have faced this issue on sites in the past, mainly FireFox and Chrome. 过去,我在主要是FireFox和Chrome的网站上都遇到过此问题。

For each CSS and Javascript file I append a parameter ?1d= to the URL. 对于每个CSS和Javascript文件,我将一个参数?1d =附加到URL。 When I deploy a change to the site that includes CSS or JavaScript it will pickup the new ID# and the end user will get the current CSS and JavaScript without the need of the hard CTRL+F5 Reset. 当我将更改部署到包含CSS或JavaScript的站点时,它将获得新的ID#,最终用户将获得当前的CSS和JavaScript,而无需进行CTRL + F5硬重置。

src="/Scripts/myJavaScript.js?id=71.11"

href="/Styles/MyStyles.css?id=71.11"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM