Make nginx avoid cache if response contains Vary Accept-Language
Posted
by
gioele
on Server Fault
See other posts from Server Fault
or by gioele
Published on 2012-09-15T18:05:19Z
Indexed on
2012/09/16
9:40 UTC
Read the original article
Hit count: 182
The cache module of nginx version 1.1.19 does not take the Vary
header into account. This means that nginx will serve the same request even if the content of one of the fields specified in the Vary
header has changed.
In my case I only care about the Accept-Language
header, all the others have been taken care of.
How can I make nginx cache everything except responses that have a Vary
header that contains Accept-Language
?
I suppose I should have something like
location / {
proxy_cache cache;
proxy_cache_valid 10m;
proxy_cache_valid 404 1m;
if ($some_header ~ "Accept-Language") { # WHAT IS THE HEADER TO USE?
set $contains_accept_language # HOW SHOULD THIS VARIABLE BE SET?
}
proxy_no_cache $contains_accept_language
proxy_http_version 1.1;
proxy_pass http://localhost:8001;
}
but I do not know what is the variable name for "the Vary
header received from the backend".
© Server Fault or respective owner