【发布时间】:2013-09-30 08:45:32
【问题描述】:
我的网页使用无缓存机制,不让浏览器缓存内容。但是,我有一些疑问。开发者没有在 MasterPage 的 PageLoad 方法中插入缓存代码。
是这样的(在主页加载页面)
HttpContext.Current.Response.CacheControl = "no-cache"
HttpContext.Current.Response.AddHeader("Pragma", "no-cache")
HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.Date
HttpContext.Current.Response.Expires = -1
我怀疑这是正确的操作,是否应该更好地将其插入BasePage OnInit 事件中?
【问题讨论】:
-
没问题,只要在生成Response之前加上就可以了
标签: asp.net header browser-cache