Accept Header / cache versioning issue

Hi Guys,

I noticed that Nginx 1.8.X is taking into account the Client Header
“Accept”
for versioning the cache objects, for instance:

This request, generates one object in cache:

curl -sv -o /dev/null 'http://www.foo.bar/image.png -H ‘Accept: /

And this, generates another one:

curl -sv -o /dev/null 'http://www.foo.bar/image.png -H ‘Accept:
text/html,
image/gif, image/jpeg, *; q=.2, /; q=.2’

This one, another one, and so on:

curl -sv -o /dev/null 'http://www.foo.bar/image.png -H ‘Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8’

Considering this behaviour:

it will generate many versions of the same object in cache, using much
more
disc resources, space, IO.

It will reduce the cache hit ratio, as a consequence, will reduce the
performance.

Then, I have a question:

Is there any way to normalize the Accept header, or even ignore it ?

Thanks in advance,

Biazus

Posted at Nginx Forum:

On Wed, Aug 19, 2015 at 12:00:21PM -0400, biazus wrote:

Hi there,

I noticed that Nginx 1.8.X is taking into account the Client Header “Accept”
for versioning the cache objects, for instance:

I don’t see it in my brief testing.

What nginx config do you use that shows this behaviour?

Then, I have a question:

Is there any way to normalize the Accept header, or even ignore it ?

Remove “$http_accept” from your “proxy_cache_key”, if it is there?

f

Francis D. [email protected]

I got it!

The “issue” was the origin server sending “Vary: Accept” header. In
order to
avoid this behaviour, simply set “proxy_ignore_headers Vary;”

Thanks!

Posted at Nginx Forum:

… or remove the ‘Vary: Accept’ header from the origin response?
​It seems this header is wreaking havoc and is useless since it won’t be
cached… why keeping it?​

B. R.