是的,你可以做到這一點,大概就
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);
}
}
但你不能刪除那麼容易......如果任何頁面需要。
(我已經包含一個頁面測試,但只是爲了看到它,你可以選擇和測試,如果你贏了所有的東西都有這個頭。)