caching - When serving a response cached by the server, IIS 7 is stripping the Vary header -


i’m using custom framework bundling stylesheets , scripts. (i.e., these dynamically generated responses, not static files.)

the response initial request, when response being generated first time, includes these headers:

http/1.1 200 ok cache-control: public, no-transform, max-age=31536000 content-type: text/css; charset=utf-8 content-encoding: gzip last-modified: mon, 25 aug 2014 18:15:50 gmt vary: accept-encoding date: tue, 09 sep 2014 16:19:36 gmt content-length: 3126 

now response above has been generated , cached server, subsequent requests same stylesheet responded these headers:

http/1.1 200 ok cache-control: public, no-transform, max-age=31536000 content-type: text/css; charset=utf-8 content-encoding: gzip last-modified: mon, 25 aug 2014 18:15:50 gmt date: tue, 09 sep 2014 16:20:00 gmt content-length: 3126 

ignoring new date value, headers identical obvious exception of missing vary header.

one nasty consequence i’ve seen in wild if first response generated given asset not compressed (due corresponding client not supporting compression), server caches non-compressed response , serves subsequent requests clients.

any idea how have server retain vary header cached responses?

i’m using httpcacheability.public these responses. can avoid issue using httpcacheability.private instead, i’d prefer allow server , proxies cache responses.

some reading has led me believe iis can’t “kernel caching” if vary encoding. i’m not sure if means can’t cache on server at all or if prevents special kind of server-side caching.

update:

i using following set vary header:

response.appendheader("vary", "accept-encoding"); 

i tried different method of specifying it:

response.cache.setvarybycustom("accept-encoding"); 

that caused vary never emitted. not on first response.

as last resort, i’m considering using:

response.cache.setnoservercaching(); 

that causes cache-control header still specify public (so proxies can still cache), prevents server caching.

in line update made question, tried yet way of specifying vary header:

response.cache.varybyheaders["accept-encoding"] = true; 

…and fixed problem. responses retain vary header across requests multiple clients , cached server.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -