0

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.

2
  • 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. 127.0.0.1) - 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, 2012 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, 2012 at 21:43

1 Answer 1

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .