Why does Chrome use client cache differently in these two scenarios?

I am working on a small one-page application using HTML5. One of the functions is to show PDF documents embedded in the page that can be selected from the list.

NOw I'm trying to get Chrome (first, and then all other modern browsers) to use the local client cache to execute a simple GET request for PDF documents without going through the server (except for the first time, of course), I force the PDF file to request by setting the "data property "in an element <object>in HTML.

I found a working example for XMLHttpRequest (not <object>). If you use the Chrome developer tools (Network tab), you can see that the first request is sent to the server and gives an answer with these headers:

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

The second request is served from the local cache without any server hop that I want.

In my own application, I then used ASP-NET MVC 4 and installed

[OutputCache(Duration=60)]

on my controller. The first request to this controller - with a URL http://localhost:63035/?doi=10.1155/2007/98732leads to the following headers:

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:*

The second request leads to another call to the server with a much faster response (suggesting server side caching?), But returns 200 OK and these headers:

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:*

A third request for the same URL results in another callback and a 304 response with these headers:

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:*

, OutputCache ( PDF, , X )?

, PDF , "data" <object>?

+5
2

. , , . , "" .

; , , , , , . , , .

, , Chrome, 2012 , , , 60 , . , , . , URL - , , URL- , - , , , (, ). : "304 - - , ". PDF .

IMHO, , .


, PDF , , , , , .

HTTP Cache-Control : private, max-age: 3600, must-revalidate. , 304 , . , data​​strong > - .

private - - , PDF , / , - .


, , , javascript, / DOM, PDF, , , .

javascript - , "", , PDF , .

+1

Location OutputCache ""

[OutputCache(Duration=60, Location = OutputCacheLocation.Client)]

location "", , , .

MSDN OutputCacheLocation

0

All Articles