Help: cache or not by cookie
Igor Sysoev
is at rambler-co.ru
Thu Jul 9 18:26:36 MSD 2009
On Thu, Jul 09, 2009 at 06:05:26AM -0400, nfn wrote:
> Thanks Igor, but how do I validate if the user is guest. I only want to show the cached version to guests.
You need to use
proxy_cache_key "http://cacheserver$request_uri $cookie_user";
proxy_cache_valid 6m;
Then in your backend you should test the "user" cookie. If it is not equal
to "guest", then you should add the "X-Accel-Redirect: 0" header in a
response. In this case nginx will not cache the response. Otherwise,
if cookie is equal to "guest" you do not need to set the header or may set
"X-Accel-Redirect: 360" to say nginx to cache the response to 6 min.
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list