强制浏览器清除缓存 [英] Force browser to clear cache

查看:250
本文介绍了强制浏览器清除缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法,我可以把一些code我的网页上,所以当有人访问一个网站,它清除浏览器缓存,这样他们就可以查看更改?

Is there a way I can put some code on my page so when someone visits a site, it clears the browser cache, so they can view the changes?

使用的语言:ASP.NET,VB.NET,当然HTML,CSS和jQuery

Languages used: ASP.NET, VB.NET, and of course html, css, and jquery.

推荐答案

如果这是关于的.css 的.js 的变化,一种方法是,以缓存无效被追加类似 _versionNo 为每个版本的文件名。例如:

If this is about .css and .js changes, one way is to to "cache busting" is by appending something like "_versionNo" to the file name for each release. For example:

script_1.0.css // This is the URL for release 1.0
script_1.1.css // This is the URL for release 1.1
script_1.2.css // etc.

或文件名之后交替做到这一点:

Or alternatively do it after the file name:

script.css?v=1.0 // This is the URL for release 1.0
script.css?v=1.1 // This is the URL for release 1.1
script.css?v=1.2 // etc.

您可以看看这个链接来看看它是如何可以工作。

You can check out this link to see how it could work.

这篇关于强制浏览器清除缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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