是的,你可以做到这一点,大概就
protected void Application_PreRequestHandlerExecute(HttpApplication sender, EventArgs e)
{
string sExtentionOfThisFile = System.IO.Path.GetExtension(HttpContext.Current.Request.Path);
if (sExtentionOfThisFile.EndsWith("aspx", true, System.Globalization.CultureInfo.InvariantCulture) ||
sExtentionOfThisFile.EndsWith("ashx", true, System.Globalization.CultureInfo.InvariantCulture) ||
sExtentionOfThisFile.EndsWith("xml", true, System.Globalization.CultureInfo.InvariantCulture)
)
{
Response.Cache.SetExpires(DateTime.Now.AddSeconds(300));
Response.Cache.SetCacheability(HttpCacheability.Public);
}
}
但你不能删除那么容易......如果任何页面需要。
(我已经包含一个页面测试,但只是为了看到它,你可以选择和测试,如果你赢了所有的东西都有这个头。)