我需要在我的 Asp.net 代码中设置到期标头。有什么方法可以通过代码添加到期标头。?
我尝试在我的 asp 页面中添加以下代码
<% System.Web.HttpContext.Current.Response.AddHeader( "Cache-Control","no-cache");
System.Web.HttpContext.Current.Response.Expires = 0;
System.Web.HttpContext.Current.Response.Cache.SetNoStore();
System.Web.HttpContext.Current.Response.AddHeader("Pragma", "no-cache");%>
<%@ OutputCache Duration="86400" Location="Client" VaryByParam="None" %>
并在我的 c# 页面中添加了以下内容...
Response.AddHeader("Expires", "Thu, 01 Dec 2014 16:00:00 GMT");
和
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetMaxAge(TimeSpan.FromSeconds(3600));
Response.Cache.SetExpires(DateTime.UtcNow.AddSeconds(3600));
并将其添加到 web,config 文件中
<clientCache httpExpires="Sun, 29 Mar 2020 00:00:00 GMT" cacheControlMode="UseExpires" />