程序化缓存

时间:2010-11-01 02:45:44

标签: c# caching

下面的代码行会做什么。

这将设置缓存时间。

Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));

这是做什么的?

Response.Cache.SetCacheability(HttpCacheability.NoCache);

这是做什么的?第一行代码集缓存然后为什么这行代码需要为真?

Response.Cache.SetValidUntilExpires(true);

提前致谢 迪夫亚

2 个答案:

答案 0 :(得分:1)

Response.Cache.SetCacheability(HttpCacheability.NoCache);

“设置Cache-Control HTTP标头.Cache-Control HTTP标头控制文档在网络上的缓存方式。” - http://msdn.microsoft.com/en-us/library/system.web.httpcachepolicy.setcacheability(v=VS.100).aspx

-

Response.Cache.SetValidUntilExpires(true);

“指定ASP.NET缓存是否应忽略客户端发送的缓存无效的HTTP缓存控件头。” - http://msdn.microsoft.com/en-us/library/system.web.httpcachepolicy.setvaliduntilexpires.aspx

答案 1 :(得分:0)

HttpCacheability.NoCache将响应头设置为no-cache,如此处所述..

http://msdn.microsoft.com/en-us/library/c4yy9w70.aspx