2
ASP.Net MVC 3 RTM。我正在嘗試在一個動作中使用OutputCache屬性,但似乎沒有工作。這是Http請求和響應。MVC 3輸出緩存問題
Request URL:http://localhost/MyApp/Employee.mvc/GetImage?userId=myUserId Request Method:GET Status Code:200 OK Request Headers Accept:*/* Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3 Accept-Encoding:gzip,deflate,sdch Accept-Language:en-US,en;q=0.8 Cache-Control:no-cache Connection:keep-alive Cookie:ASP.NET_SessionId=sessionIdStuff Host:localhost Pragma:no-cache Referer:http://localhost/MyApp/Employee/Review/1/Index User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US)
爲AppleWebKit/534.13(KHTML,像壁虎) 鉻/ 9.0.597.98 Safari/534.13 查詢字符串參數 用戶名:MYUSER 響應頭 緩存控制:私人的,沒有商店,最大-age = 3484
Content-Length:1428 Content-Type:image/jpeg Date:Wed, 16 Feb 2011 22:59:14 GMT Expires:Wed, 16 Feb 2011 23:57:19 GMT Last-Modified:Wed, 16 Feb 2011 22:57:19 GMT Server:Microsoft-IIS/5.1 Vary:* X-AspNet-Version:4.0.30319 X-AspNetMvc-Version:3.0 X-Powered-By:ASP.NET
這裏是控制器:
[HttpGet, OutputCache(Location= OutputCacheLocation.Client, VaryByParam="userId", Duration=3600, NoStore=true)]
public FileContentResult GetImage(string userId)
{
byte[] result;
using (var client = new WebClient())
{
client.Credentials = CredentialCache.DefaultCredentials;
result = client.DownloadData(string.Format(IntranetUrl, userId));
}
return File(result, "image/jpeg");
}
,我的觀點:
<img alt="Employee Picture" src='@Url.Action("GetImage", "Employee", new { userId = Model.UserId, area=""})' width="75px" height="100px" />
我試圖與那些獲得了緩存的其他靜態圖像和唯一的區別比較在這些線:
的Cache-Control:私人的,沒有商店, max-age = 3484
這包含在我的動作中,但不包含在靜態圖像中。此外,靜態圖像有一個ETag,但我的行動反應沒有。
任何人都可以幫助爲什麼這可能不緩存在瀏覽器中?
感謝您的幫助..