My Rails 3.2 app uses — via #stale?
— If-Modified-Since
HTTP header in the request and Last-Modified
header in the response to decide whether it should generate some data dynamically. This works extremely well in development (whether using webrick or unicorn_rails) as curl -D headers.txt
shows that if the correct If-Modified-Since
value is provided a 304 response is sent, while the Last-Modified
header is otherwise sent along the request data.
Unfortunately once deployed behind nginx, neither If-Modified-Since
(providing the correct header value) is passed to unicorn — and thus the Rails app — nor Last-Modified
is propagated to the client: the request is unconditionally generated and the response never contains the proper headers.