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'm using nginx to serve a sinatra based project which has fairly static content..

I've tried to combine this:

with the proxying solution offered elsewhere on this site: How to set up Nginx as a caching reverse proxy?

Coming up with...

But for some reason, nothing is ever written to cache. I've made sure nginx owns the folder used for caching, and there are no errors in the error.log..

Apologies for the semi-reproduced content, but I couldn't find a good guide to combining the two.

share|improve this question
up vote 0 down vote accepted


Nginx version 0.8.44+ does not cache upstream responses with Set-Cookie header. Make sure your backend does not issue it.


"If is Evil", rewrite your config to smth like

location / {
  # ...

location ~ \.(ico|css|js|gif|jpe?g|png)$ {
  expires max;

Locations match a path, not arguments. That's why I omitted the last part of your regular expression that was supposed to match a query string.

share|improve this answer
Thanks. Removing "set cookies" solved it. – minikomi Aug 29 '11 at 2:08

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.