Reputation: 6713
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.
Upvotes: 1
Views: 1803
Reputation: 6713
It turns out nginx was actually not stripping anything. Instrumentation showed that If-Modified-Since
was received by the controller. Rails #stale?
was receiving a request containing bad results, which resulted in a nil
argument, swallowing it silently and subsequently ignoring comparisons to If-Modified-Since
and positioning Last-Modified
to nil
.
Upvotes: 1