<div dir="ltr"><div>Hi guys,</div><div><br></div><div>I'm building a small nginx reverse proxy to take care of a bunch of static files for my clients - and it works great.</div><div><br></div><div>One thing I'm facing though is that some client sites sent "Vary: Accept-Encoding, User-Agent" - which gives an awful cache hit rate - since proxy_cache takes this into account, unless I use something like "proxy_ignore_headers Vary;"</div><div><br></div><div>But ignoring Vary headers can cause other issues such as gzipped content being sent to a non-gzip client.</div><div><br></div><div>So I'm looking for a way to basically rewrite the vary header to "Vary: Accept-Encoding" before storing it in proxy_cache - but I wonder if this is even possible in nginx, and if yes - can you give any pointers?</div><div><br></div><div>I found a temporary fix, and that is to ignore the Vary header, and using a custom variable as a part of the cache key, that is either "", "gzip" or "deflate" (I use a map to look at the Accept-Encoding header from the client).</div><div><br></div><div>This works great - but I rather keep the cache key a bit clean (since I'll use it later)</div><div><br></div><div>Do you guys have any recommendations how to make this happen?</div><div><br></div><div>Also as a side note, if I remove the custom variable from the cache key, how would one actually purge the file then? I assume I have to send different purge requests, since the cached file is based on the Vary: accept-encoding - so I'd have to purge at least the amount of cached encodings right?</div><div><br></div><div>Also I could opt for another way, and that's always requesting a uncompressed file from the origin (Is it simply not sending the accept-encoding header, or should I do something else?), and then on every request either decide to gzip it or not - the downside I see here, is the fact that most clients request gzip,deflate content, so having to compress on every request will use additional CPU resources.</div><div><br></div><div>Thanks in advance!</div><div><br></div><div><div class="gmail_signature"><div dir="ltr"><div>--</div>Best regards,<div>Lucas Rolff</div></div></div></div>
</div>