配置文件
<configuration>
<system.web>
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="outputCache60" duration="60" enabled="true" location="Client" varyByParam="*" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
<compilation debug="true"/>
</system.web>
</configuration>
页面文件
<%@ OutputCache CacheProfile="outputCache60" %> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <%=DateTime.Now %> </div> </form> </body> </html>
配置文件中设置 location="Client" 模式,缓存在客户端浏览器上,但是每次刷新客户端,状态码都是200 不是 304 ,各位大侠这是为啥?
指定OutputCache中的属性Location=”Client”表示客户端缓存,当用户在浏览器中点击“后退”按钮或在地址栏中重新输入URL,在这种情况下,浏览器将从缓存获取页面,如果用户点击“刷新”按钮,那么浏览器中缓存将失效,浏览器发送页面请求。至于状态码为200和304是在不同的浏览器表现是不一样的。
3q