title: Why does Chrome use the client cache differently in these two scenarios?
body: <p>I'm working on a small single-page application using HTML5. One feature is to show PDF documents embedded in the page, which documents can be selected form a list.</p>
  
  <p>NOw I'm trying to make Chrome (at first, and then all the other modern browsers) use the local client cache to fulfill simple GET request for PDF documents without going through the server (other than the first time of course). I cause the PDF file to be requested by setting the "data" property on an <code>&lt;object&gt;</code> element in HTML.</p>
  
  <p>I have found a <a href="http://www.httpwatch.com/demos/ajax_caching/" rel="noreferrer">working example for XMLHttpRequest</a> (not <code>&lt;object&gt;</code>). If you use Chrome's developer tools (Network tab) you can see that the first request goes to the server, and results in a response with these headers:</p>
  
  <pre><code>Cache-Control:public,Public
  Content-Encoding:gzip
  Content-Length:130
  Content-Type:text/plain; charset=utf-8
  Date:Tue, 03 Jul 2012 20:34:15 GMT
  Expires:Tue, 03 Jul 2012 20:35:15 GMT
  Last-Modified:Tue, 03 Jul 2012 20:34:15 GMT
  Server:Microsoft-IIS/7.5
  Vary:Accept-Encoding
  </code></pre>
  
  <p>The second request is served from the local cache without any server roundtrip, which is what I want.</p>
  
  <p>Back in my own application, I then used ASP-NET MVC 4 and set</p>
  
  <pre><code>[OutputCache(Duration=60)]
  </code></pre>
  
  <p>on my controller. The first request to this controller - with URL <code>http://localhost:63035/?doi=10.1155/2007/98732</code> results in the following headers:</p>
  
  <pre><code>Cache-Control:public, max-age=60, s-maxage=0
  Content-Length:238727
  Content-Type:application/pdf
  Date:Tue, 03 Jul 2012 20:45:08 GMT
  Expires:Tue, 03 Jul 2012 20:46:06 GMT
  Last-Modified:Tue, 03 Jul 2012 20:45:06 GMT
  Server:Microsoft-IIS/8.0
  Vary:*
  </code></pre>
  
  <p>The second request results in another roundtrip to the server, with a much quicker response (suggesting server-side caching?) but returns 200 OK and these headers:</p>
  
  <pre><code>Cache-Control:public, max-age=53, s-maxage=0
  Content-Length:238727
  Content-Type:application/pdf
  Date:Tue, 03 Jul 2012 20:45:13 GMT
  Expires:Tue, 03 Jul 2012 20:46:06 GMT
  Last-Modified:Tue, 03 Jul 2012 20:45:06 GMT
  Server:Microsoft-IIS/8.0
  Vary:*
  </code></pre>
  
  <p>The third request for the same URL results in yet another roundtrip and a 304 response with these headers:</p>
  
  <pre><code>Cache-Control:public, max-age=33, s-maxage=0
  Date:Tue, 03 Jul 2012 20:45:33 GMT
  Expires:Tue, 03 Jul 2012 20:46:06 GMT
  Last-Modified:Tue, 03 Jul 2012 20:45:06 GMT
  Server:Microsoft-IIS/8.0
  Vary:*
  </code></pre>
  
  <p><strong>My question is</strong>, how should I set the OutputCache attribute in order to get the desired behaviour (i.e. PDF requests fullfilled from the client cache, within X seconds of the initial request)?</p>
  
  <p>Or, am I not doing things right when I cause the PDF to display by setting the "data" property on an <code>&lt;object&gt;</code> element?</p>