Welcome! Log In Create A New Profile

Advanced

Re: Proxying and caching a fragile server to ensure availability

August 21, 2013 10:35PM
B.R. Wrote:
-------------------------------------------------------
> Hello,
>
> On Wed, Aug 21, 2013 at 9:42 PM, cachito <nginx-forum@nginx.us> wrote:
>
> > if ($http_cookie ~*
> >
> "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in")
> {
> > set $no_cache 1;
> > }
> >
>
> ​​If the user sends requests using cookies from Wordpress, the cache
> won't
> be used...
> Thus, you seem not to cache requests from Wordpress at all. That CMS
> need
> resources such as power and generates huge traffic (that needs to be
> processed aswell).
> Are you sure not all the Wordpress requests contain cookie(s)?
> ​

I'm manually deleting cookies to force caching and it isn't happening. Even if I set $no_cache to 0 in this particular section (or at the end of the if list) nothing happens.

>
>
> > #The different cache zones reside in different filesystems. the
> "pages"
> > zone
> > is saved in RAM for fast delivery.
> > location / {
> > proxy_pass http://upstream;
> > proxy_cache pages;
> > proxy_cache_key $cache_key;
> > proxy_cache_valid 60m; # I was hoping to have the proxy query
> the
> > upstream once every hour for updated content.
> >
>
> ​​Read the correct syntax and use of proxy_cache_valid.
> If no HTTP code is specified as optional parameter, it says 'then only
> 200,
> 301 and 302 responses are cached'.

This is the intended behavior. If the upstream responds something useful, cache it and serve it. Errors shouldn't be cached, and the stale cache should be served for that URL.

> ​
>
>
> > # 2 rules to dedicate the no caching rule for logged in users.
> > proxy_cache_bypass $no_cache; # Do not cache the response.
> > proxy_no_cache $no_cache; # Do not serve response from cache.
> >
>
> ​​Actually, those 2 comments are inverted: proxy_no_cache controls
> whether
> or not items should be written in cache and proxy_cache_bypass
> controls
> whether or not content should be read from it.

Comments aside, when $no_cache is set to 0 it mandates that the upstream response should be cached and the client should be served content from cache, right?


Thanks B. R.
> ​
>
>
> > add_header X-Cache $upstream_cache_status;
> > expires 60m;
> > }
> >
> ---
> *B. R.*
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Proxying and caching a fragile server to ensure availability

cachito August 21, 2013 09:42PM

Re: Proxying and caching a fragile server to ensure availability

B.R. August 21, 2013 10:26PM

Re: Proxying and caching a fragile server to ensure availability

cachito August 21, 2013 10:35PM

Re: Proxying and caching a fragile server to ensure availability

B.R. August 21, 2013 10:54PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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