我使用的輸出緩存在我的自定義HTTP處理程序以下列方式:輸出緩存和SetValidUntilExpires
public void ProcessRequest(HttpContext context)
{
TimeSpan freshness = new TimeSpan(0, 0, 0, 60);
context.Response.Cache.SetExpires(DateTime.Now.Add(freshness));
context.Response.Cache.SetMaxAge(freshness);
context.Response.Cache.SetCacheability(HttpCacheability.Public);
context.Response.Cache.SetValidUntilExpires(true);
...
}
它的工作原理,但問題是,刷新與F5的頁面導致頁面再生(而不是緩存使用情況):
context.Response.Cache.SetValidUntilExpires(true);
有什麼建議嗎?
UPD:似乎問題的原因是HTTP處理程序響應沒有在服務器上緩存。下面的代碼可以很好地用於Web的形式,而不是處理程序:
Response.Cache.SetCacheability(HttpCacheability.Server);
是否有緩存服務器上的HTTP處理程序響應的一些具體?
感謝您找到此解決方案,爲我提供單值查詢參數。但是當我有一個像'?id = 1&id = 2&id = 3'這樣的多值參數時,這仍然不起作用。我不知道爲什麼,但想讓別人知道它。 – Oliver 2013-05-23 16:48:01