# Accept Header / cache versioning issue

**URL:** <https://www.ruby-forum.com/t/accept-header-cache-versioning-issue/243073>\
**Category:** NGINX\
**Created:** [August 19, 2015, 6:00pm UTC](https://www.ruby-forum.com/t/accept-header-cache-versioning-issue/243073 "2015-08-19T18:00:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [August 19, 2015, 6:00pm UTC](https://www.ruby-forum.com/t/accept-header-cache-versioning-issue/243073/1 "2015-08-19T18:00:41Z")

</div>

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](http://www.foo.bar/image.png) -H ‘Accept: _/_’

And this, generates another one:

curl -sv -o /dev/null '[http://www.foo.bar/image.png](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](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:

> **[Accept Header / cache versioning issue](https://forum.nginx.org/read.php?2,261128,261128#msg-261128)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![biazus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b3f665/32.png) [@biazus](https://www.ruby-forum.com/u/biazus)\
**Post date:** [August 19, 2015, 7:35pm UTC](https://www.ruby-forum.com/t/accept-header-cache-versioning-issue/243073/2 "2015-08-19T19:35:54Z")

</div>

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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![biazus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b3f665/32.png) [@biazus](https://www.ruby-forum.com/u/biazus)\
**Post date:** [August 19, 2015, 7:42pm UTC](https://www.ruby-forum.com/t/accept-header-cache-versioning-issue/243073/3 "2015-08-19T19:42:55Z")

</div>

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:

> **[Re: Accept Header / cache versioning issue](https://forum.nginx.org/read.php?2,261128,261131#msg-261131)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![biazus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b3f665/32.png) [@biazus](https://www.ruby-forum.com/u/biazus)\
**Post date:** [August 19, 2015, 11:00pm UTC](https://www.ruby-forum.com/t/accept-header-cache-versioning-issue/243073/4 "2015-08-19T23:00:24Z")

</div>

## … 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._
