Nginx generating different md5 sums for same key causing cache to become corrupt

Maxim Dounin mdounin at
Tue Mar 29 13:07:17 UTC 2016


On Tue, Mar 29, 2016 at 08:36:37AM -0400, pirish wrote:

> Hello,
>   Currently we use nginx 1.8.1 on redhat 7.  We have reverse proxy caching
> enabled but are experiencing unexpected behaviour.  Our caching key is
> $scheme$request_method$host$request_uri$.  On the first visit to a page, a
> cache file with the correct md5 sum of the key is created.  If you visit the
> same url from the same browser, but a different tab, a new cache file is
> created with different md5 sum, but same content.  The next time you visit
> the url from that browser, it will be random which page is selected from the
> cache.  Now if you visit from a second browser a 3rd cache file will be
> created.  Reloading from any browser or tab will randomly pick one of the
> created files.  Are there other factors in creating the md5 other than the
> cache key ?

When a response uses Vary mechanism, multiple representation may 
be stored in cache under secondary cache keys derived from the 
request headers listed in Vary.  You can use proxy_ignore_headers 
to instruct nginx to ignore Vary headers in response, see

Maxim Dounin

More information about the nginx mailing list