Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC 3 Output Cache Problem
    primarykey
    data
    text
    <p>ASP.Net MVC 3 RTM. I am trying to use the OutputCache attribute in an action, but doesn't appear to be working. Here is the Http Request and Response.</p> <blockquote> <pre><code>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) </code></pre> <p>AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.98 Safari/534.13 Query String Parameters userId:myUser Response Headers Cache-Control:private, no-store, max-age=3484</p> <pre><code>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 </code></pre> </blockquote> <p>Here is the controller:</p> <pre><code> [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"); } </code></pre> <p>and my View:</p> <pre><code>&lt;img alt="Employee Picture" src='@Url.Action("GetImage", "Employee", new { userId = Model.UserId, area=""})' width="75px" height="100px" /&gt; </code></pre> <p>I tried comparing with other static images that are getting cached and the only differences where these lines:</p> <blockquote> <p>Cache-Control:private, no-store, max-age=3484</p> </blockquote> <p>This is included in my action, but not in the static images. Also, the static images had an ETag, but my action response did not. </p> <p>Can anyone help why this might not be cached in the browser?</p> <p>Thanks for any help..</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload