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

**URL:** <https://www.ruby-forum.com/t/nginx-generating-different-md5-sums-for-same-key-causing-cache-to-become-corrupt/244373>\
**Category:** NGINX\
**Created:** [March 29, 2016, 2:37pm UTC](https://www.ruby-forum.com/t/nginx-generating-different-md5-sums-for-same-key-causing-cache-to-become-corrupt/244373 "2016-03-29T14:37:10Z")\
**Posts on this page:** 2\
**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:** [March 29, 2016, 2:37pm UTC](https://www.ruby-forum.com/t/nginx-generating-different-md5-sums-for-same-key-causing-cache-to-become-corrupt/244373/1 "2016-03-29T14:37:10Z")

</div>

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 ?

Posted at Nginx Forum:

> **[Nginx generating different md5 sums for same key causing cache to become corrupt](https://forum.nginx.org/read.php?2,265703,265703#msg-265703)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![pirish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7feea3/32.png) [@pirish](https://www.ruby-forum.com/u/pirish)\
**Post date:** [March 29, 2016, 3:07pm UTC](https://www.ruby-forum.com/t/nginx-generating-different-md5-sums-for-same-key-causing-cache-to-become-corrupt/244373/2 "2016-03-29T15:07:33Z")

</div>

Hello!

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

> 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  
[Module ngx\_http\_proxy\_module](http://nginx.org/r/proxy_ignore_headers).

–  
Maxim D.

> **[nginx](http://nginx.org/)**
