Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 管理web浏览器的缓存_Javascript_Asp.net_Caching_Webforms - Fatal编程技术网

Javascript 管理web浏览器的缓存

Javascript 管理web浏览器的缓存,javascript,asp.net,caching,webforms,Javascript,Asp.net,Caching,Webforms,我试图避免在浏览器中存储缓存,但我的应用程序url仍然显示在缓存中 我在母版页的页面加载方法中使用了以下代码来禁用浏览器缓存: Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache); Response.Cache.SetAllowResponseInBrowserHistory(false); Response.Cache.SetCacheability(HttpCacheability.NoCache); Respo

我试图避免在浏览器中存储缓存,但我的应用程序url仍然显示在缓存中

我在母版页的页面加载方法中使用了以下代码来禁用浏览器缓存:

Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);
Response.Cache.SetAllowResponseInBrowserHistory(false);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
Response.Cache.SetNoStore();
Response.AddHeader("Pragma", "no-cache");
也可以尝试在html页面中使用meta标记,但仍在以下浏览器路径中缓存显示:
1.chrome://cache/

2.关于:缓存?存储=磁盘和上下文=

您可以通过执行以下步骤避免存储缓存
1.转到
应用程序启动

2.单击过滤器配置文件。
3.在文件中输入以下代码

public class NoCacheResponseHeaderFilter:ActionFilterAttribute
    {
        public override void OnActionExecuted(ActionExecutedContext actionExecutedContext)
        {
            actionExecutedContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            actionExecutedContext.HttpContext.Response.Cache.AppendCacheExtension("no-store,must-revalidate");
            actionExecutedContext.HttpContext.Response.AppendHeader("Pragma", "no-cache");
            actionExecutedContext.HttpContext.Response.AppendHeader("Expires", "Fri, 01 Jan 1990 00:00:00 GMT");
        }
    }
上述代码将在刷新浏览器时清除浏览器缓存,因为它将在页面呈现之前调用筛选方法。
希望这有帮助