Hello!
On Tue, Nov 08, 2011 at 11:56:53AM -0500, lpugoy wrote:
> I'm sorry, but I don't understand the effect of cookies on proxy
> caching. I'm trying to implement the same configuration as the one
> referred to, and I'm also having trouble in that it doesn't seem to be
> caching. I'm also using httperf. For every request the backend does
> return a different cookie. Is this what is preventing the caching from
> happening?
Yes, nginx won't cache responses with cookies unless you
specifically ask it to via proxy_ignore_headers directive[1].
Please also note that if you do so, you may want to also instruct
nginx to hide returned cookies from clients (via proxy_hide_header
directive[2]), or you'll end up with multiple clients with the
same cookie.
Example configuration should look like:
proxy_ignore_headers Set-Cookie;
proxy_hide_header Set-Cookie;
Depending on the actual headers your backend returns you may also
need to ignore other headers as well for cache to work, notably
Expires and Cache-Control.
Alternatively, you may want to instruct your backend to not return
headers which prevent caching.
[1] http://wiki.nginx.org/HttpProxyModule#proxy_ignore_headers
[2] http://wiki.nginx.org/HttpProxyModule#proxy_hide_header
> In the debug log, I found some entries that refer to the cache. They are
> below:
>
> 2011/11/08 20:51:45 [debug] 21434#0: *1 http cache key:
> "httpwww.site.comGET/"
> 2011/11/08 20:51:45 [debug] 21434#0: *1 http script var: ""
> 2011/11/08 20:51:45 [debug] 21434#0: *1 add cleanup: 091D56A4
> 2011/11/08 20:51:45 [debug] 21434#0: shmtx lock
> 2011/11/08 20:51:45 [debug] 21434#0: slab alloc: 76 slot: 4
> 2011/11/08 20:51:45 [debug] 21434#0: slab alloc: B6F6B000
> 2011/11/08 20:51:45 [debug] 21434#0: shmtx unlock
> 2011/11/08 20:51:45 [debug] 21434#0: *1 http file cache exists: -5 e:0
> 2011/11/08 20:51:45 [debug] 21434#0: *1 cache file:
> "/var/cache/nginx/5/86/629d786ceca8ff787779a3e4ccdc8865"
> 2011/11/08 20:51:45 [debug] 21434#0: *1 add cleanup: 091D56E8
> 2011/11/08 20:51:45 [debug] 21434#0: *1 http upstream cache: -5
>
> What do they mean? Thank you.
This debug lines correspond to lookup of the request in cache, and
they show that no cached response exists.
Maxim Dounin
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx