0

我设置了这些缓存标头

    Context.Response.Cache.SetExpires(DateTime.Now.Add(refresh));
    Context.Response.Cache.SetMaxAge(refresh);
    Context.Response.Cache.SetCacheability(HttpCacheability.Private);
    Context.Response.Cache.SetValidUntilExpires(true);
    Context.Response.ContentType = "text/html";

当页面刷新时,我是否还必须设置其他任何东西才能使缓存工作?

4

1 回答 1

0

对于以编程方式将页面内容放置在客户端(浏览器)、代理和服务器缓存中,您需要执行以下操作:

Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetExpires(DateTime.Now.AddSeconds(15));
Response.Cache.SetMaxAge(TimeSpan.FromSeconds(15));
Response.Cache.SetValidUntilExpires(true);
Response.Cache.SetLastModified(DateTime.Now);
Response.Cache.SetOmitVaryStar(true);
于 2014-09-12T01:27:07.830 回答