2010-08-03 65 views
0

我使用以下代碼在* .png請求上寫入緩存頭: response.Buffer = false; response.BufferOutput = false;asp.net MVC的緩存和Firefox的緩存如何工作?

 // Emit content type and encoding based on the file extension and 
     // whether the response is compressed 
     response.ContentType = MimeMapping.GetMimeMapping(physicalFilePath); 
     if (mode != ResponseCompressionType.None) 
      response.AppendHeader("Content-Encoding", mode.ToString().ToLower()); 
     response.AppendHeader("Content-Length", count.ToString()); 

     // Emit proper cache headers that will cache the response in browser's 
     // cache for the default cache duration 
     response.Cache.SetCacheability(HttpCacheability.Public); 
     response.Cache.AppendCacheExtension("must-revalidate, proxy-revalidate"); 
     response.Cache.SetMaxAge(DEFAULT_CACHE_DURATION); 
     response.Cache.SetExpires(DateTime.Now.Add(DEFAULT_CACHE_DURATION)); 
     response.Cache.SetLastModified(lastModified); 

但每次刷新包含PNG URL的頁面時,它都會重新發布到Web服務器。看起來緩存頭不起作用,更糟糕的是,它使瀏覽器緩存不能工作。

我使用的是asp.net mvc。 有人能指出我正確的方向嗎?謝謝 !

回答

0

A POST從來沒有被任何瀏覽器或服務器緩存。如果瀏覽器發出POST請求,則服務器執行它。您無法緩存結果。唯一不是POST的方法是不發行POST