Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have nginx as a reverse proxy to a remote web server. Cache is written to file. However, when I place Varnish in front of it, nginx stops writing to cache file, which causes a performance hit and it doubles the traffic.

How it is possible that a front-end (Varnish) can tell nginx not to cache those requests? I tried to debug but not found anything. My nginx configuration is something like this:

server {
  location / {
    proxy_ignore_headers Set-Cookie Expires Cache-Control;
    proxy_cache p-cache;

Again, if I make direct request to nginx, there is no problem. But I have to use Varnish which is the unique door to other service to that server.

share|improve this question
Some additional information, such as your Varnish config, might be helpful. However, two guesses - 1) Adding a front end server causes requests to originate from that IP (e.g. - since some caching and scripts depend on the IP - ensure it is set correctly. 2) Varnish can change the request sent to the backend (e.g. modifying headers, stripping cookies, etc - watch some requests reaching the backend with varnishlog to see what is making it through). – cyberx86 Jan 31 '12 at 20:31
I've found the problem. See my answer below. About cookies, headers... I already ignore all them in the conf that I posted above. This is my set up for edge side caching of media content, so I don't care about IP address, cookie, user agent etc. – jcisio Jan 31 '12 at 21:43
up vote 1 down vote accepted

I've found it. It is because of proxy_cache_min_uses = 3 that I set in another place. With this declarative, nginx won't cache to file when there are less than 3 hits on the same url.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.