Welcome! Log In Create A New Profile

Advanced

Re: Proxy cache for php site

November 09, 2011 06:02AM
Maxim Dounin Wrote:
-------------------------------------------------------
> 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_h
> eader
>

Hello.

Thank you for the explanation. I now understand the problem and it is now working.

I want to add a condition where if a cookie with the name sess_id is included in the request, then the cache would be bypassed. I tried the following

if ($http_cookie ~* "sess_id") {
set $no_cache "1";
}

proxy_no_cache $no_cache;
proxy_cache_bypass $no_cache;

but it doesn't seem to work. What is the correct way to do this? Thank you very much.
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: 109
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready