Welcome! Log In Create A New Profile

Advanced

Re: Reverse Proxy Cache Setup

Ryan Malayter
March 29, 2010 01:10PM
On Mon, Mar 29, 2010 at 11:44 AM, royo <nginx-forum@nginx.us> wrote:
>
> Thanks Ryan. I don't have much control over the application itself, so I guess I'd need to enforce the caching somehow for users that are logged in and disable it for those that aren't from nginx.
>

If you include a unique string in your nginx proxy_cache_key, then
logged-in user requests should never be in cache (again, assuming the
back-end sets cache-control headers).

So, assuming you have "proxy_cache_key
$http_host$request_uri$http_cookie_logmein" in your nginx config:

A request for http://mine.example.com/foo from an anonymous user would
get nginx cache key:
http://mine.example.com/foo <-- logmein is empty
This result could be served from cache for future anonymous requests

A request for http://mine.example.com/foo from a a logged in user user
would get nginx cache key:
http://mine.example.com/fooAB324494354CD43254DC <-- logmein
contains user's session ID
In this case, there would not be a cache hit on the nginx side, and a
logged in user's request is passed to the back-end and they get a
customized version of the page. No anonymous users would ever see that
because they don't have that session ID. Presumably, the back-end must
set "Cache-Control: private" or "Cache-Control: no-cache" for
logged-in users. If it doesn't, you're really going to have problems.

I do not think that nginx proxy directives are allowed inside an "if"
block. You might be able to use "if $http_cookie_logmein" to redirect
internally to a named nginx location that does not have any caching.

Can you post your nginx configuration?


--
RPM

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Reverse Proxy Cache Setup

royo March 29, 2010 09:41AM

Re: Reverse Proxy Cache Setup

Ryan Malayter March 29, 2010 11:50AM

Re: Reverse Proxy Cache Setup

royo March 29, 2010 12:44PM

Re: Reverse Proxy Cache Setup

Ryan Malayter March 29, 2010 01:10PM

Re: Reverse Proxy Cache Setup

royo March 29, 2010 01:19PM

Re: Reverse Proxy Cache Setup

Ryan Malayter March 30, 2010 11:10PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 198
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready