部署后清除缓存 [英] Clearing cache once on deploy

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

问题描述

我正在尝试找出最简单的方法是迫使最终用户浏览器清除缓存.

I'm trying to figure out how the easiest way would be to force endusers browser to clear cache.

我们正在使用.Net WebForms和AngularJs在Visual Studio中工作

We are working in visual studio with .Net WebForms and AngularJs

因此,每次我们将.Net项目部署到测试或生产环境时,都会遇到缓存保存旧JavaScript并隐藏新实现的问题...

So every time we deploy our .Net project to test or production enviroment we got problems with cache saving old javascript and hides new implementation...

我知道几个解决方案,但我想看看是否还有其他解决方案?

I know a couple solutions but I wanna see if there are any other?

提前谢谢!

推荐答案

右键单击此页面并选择查看源,您将看到后缀如下的静态文件:

Right click in this page and select view source, you will see static files suffixed as follows:

<script src="//cdn.sstatic.net/Js/stub.en.js?v=b1fcfe635df7"></script>

基本上,这是一种最佳方法,生成一些后缀并将其作为querystring参数附加到所有静态文件的末尾.这将迫使浏览器认为该文件是新文件,即查询字符串是否已更改...

Basically this is kind of the best method, generate some suffix and append that to the end of all of your static files as a querystring parameter. That will force the browser into thinking that the file is new, i.e. if the querystring has changed...

这里的问题是您多久更改一次这些文件...您要多久强制一次用户下载新的静态文件...使用生成的时间戳可能会迫使用户每次访问时都下载文件该网站,通常并不理想....也许使用web.config日期或类似的日期.

The rub here though is how often do you change those files... how often do you want to force the user to download new static files... using a generated timestamp could force the user to download the file everytime they visit the site, often not ideal.... Maybe use the web.config date or something like it.

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

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