添加代码4从高速缓存中删除页面 [英] whr to add code 4 remove page from cache
问题描述
其中添加了以下代码.在AddHeader中,对所有固定的"Pragma"是固定的
var lastModified = DateTime.UtcNow;
var expires = lastModified-TimeSpan.FromDays(365);
Response.Cache.SetExpires(expires);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Response.CacheControl =无缓存";
Response.AddHeader("Pragma","no-cache");
where the following code is added .in AddHeader what is "Pragma" is it fixed for all
var lastModified = DateTime.UtcNow;
var expires = lastModified - TimeSpan.FromDays(365);
Response.Cache.SetExpires(expires);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Response.CacheControl = "no-cache";
Response.AddHeader("Pragma", "no-cache");
推荐答案
请编辑原始帖子,如果您需要更多信息.这与另一个问题有关.而且,为什么不先尝试就问这个问题?放在哪里都没关系.
Please, edit your original post if you need more info. This relates to another question. And, why did you ask this without first trying it ? It doesn''t matter where you put it.
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
我相信,仅靠它自己就能解决问题.无论哪种方式,无论将其放在哪里,都可以将所有这些代码放在页面中或您使用的基类中.
by itself will fix the problem, I believe. Either way, putting all this code somewhere in your page, or in a base class that you use, will work, no matter where you put it.
Response.AddHeader("Pragma", "no-cache");
在页面正确解析之前无法正常工作.因此,最好使用此meta标签在页面底部写一个新的标题.
实际上,在达到其缓冲区大小的一半后,它会在高速缓存中查找该页面.
因此您的页面可能看起来像
Response.AddHeader("Pragma", "no-cache");
doesnt work before the page is actually parsed properly. So if is better to write a new head at the bottom of the page with this meta tag.
It actually goes to find the page in the cache after the half of its buffer size is reached.
So your page might look like
<html>
<head>
<meta HTTP-EQUIV="REFRESH" content="5">
<title>New Title </TITLE>
</head>
<body>
Blah !! Blah !! Blah !! Blah !! Blah !!
</body>
<head>
<meta HTTP-EQUIV="PRAGMA" content="NO-CACHE">
</head>
</html>
:)
:)
这篇关于添加代码4从高速缓存中删除页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!