[英]How to clear all cache in browser using ASP.net(C#)
我尝试使用此代码清除缓存,但它不适用于 Google Chrome。 我需要清除浏览器中的所有缓存或清除所有网站缓存(不仅仅是一页) Ps:大多数使用小部件 DOJO javascript 的代码,为什么我需要清除所有缓存。
List<string> keys = new List<string>();
// retrieve application Cache enumerator
IDictionaryEnumerator enumerator = Cache.GetEnumerator();
// copy all keys that currently exist in Cache
while (enumerator.MoveNext())
{
keys.Add(enumerator.Key.ToString());
}
// delete every key from cache
for (int i = 0; i < keys.Count; i++)
{
Cache.Remove(keys[i]);
}
HttpRuntime.Close();
谢谢你的每一个答案。
您可以尝试这样清除浏览器的所有缓存
HttpContext.Current.Response.AddHeader("Cache-Control", "no-cache, no-store, must-revalidate");
HttpContext.Current.Response.AddHeader("Pragma", "no-cache");
HttpContext.Current.Response.AddHeader("Expires", "0");
您还可以参考: 确保网页不被缓存,跨所有浏览器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.