Reverse Proxy Cache Setup

Ryan Malayter malayter at
Wed Mar 31 07:04:33 MSD 2010

On Mon, Mar 29, 2010 at 1:29 PM, royo <nginx-forum at> wrote:
> The app sets "Cache-Control: private" right now for everyone,
> and with the following setup even users that are not logged in
> receive a fresh copy of the page every time. The said cookie
> is set when logging in to the domain actual
> domain) as well as other cookies but when using the nginx
> proxy only the other cookies are set and the logmein cookie
> isn't visible.

If nginx can see one cookie for /, it should see them all unless it is
scoped improperly. Have you used fiddler or Firebug to be sure that
the cookie isn't ebing set and passed?

Secondly, if the back-end is setting Cache-Control: private, then
nginx will obey and not cache anything. Changing the back-end to set
"Cache-Control: public,max-age=3600" or whatever is the easiest route.

If you can't do that, you can do something like this with "if" and
rewrite, to a location that does not use the cache at all  for logged
in user requests. $http_cookie_logmein should be accessible for such
requests, you can echo it back for debuggin using:

   add_header "X-Logmein-Received" $http_cookie_logmein

Once again, debugging with Fiddler or Firebug will let you see these
headers and work out the kinks.

More information about the nginx mailing list