Welcome! Log In Create A New Profile

Advanced

Re: Proxy cache for php site

Maxim Dounin
November 08, 2011 04:32PM
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
Subject Author Posted

Proxy cache for php site

Jon Bennett October 15, 2011 07:42PM

Re: Proxy cache for php site

António P. P. Almeida October 15, 2011 08:52PM

Re: Proxy cache for php site

Jon Bennett October 15, 2011 09:18PM

Re: Proxy cache for php site

António P. P. Almeida October 15, 2011 10:56PM

Re: Proxy cache for php site

Jon Bennett October 16, 2011 08:26AM

Re: Proxy cache for php site

Jon Bennett October 16, 2011 07:04PM

Re: Proxy cache for php site

lpugoy November 08, 2011 07:55AM

Re: Proxy cache for php site

Francis Daly November 08, 2011 04:30PM

Re: Proxy cache for php site

Maxim Dounin November 08, 2011 04:32PM

Re: Proxy cache for php site

lpugoy November 09, 2011 06:02AM

Re: Proxy cache for php site

lpugoy November 09, 2011 08:18AM

Re: Proxy cache for php site

lpugoy November 10, 2011 02:50AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 160
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