Proxying and caching a fragile server to ensure availability

B.R. reallfqq-nginx at yahoo.fr
Thu Aug 22 02:53:00 UTC 2013


Hello,


On Wed, Aug 21, 2013 at 10:35 PM, cachito <nginx-forum at nginx.us> wrote:

> B.R. Wrote:
> -------------------------------------------------------
> > Hello,
> >
> > On Wed, Aug 21, 2013 at 9:42 PM, cachito <nginx-forum at 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.
>

​Is your conf really applied? Check logs on reload to be sure.
​


>
> >
> >
> > > #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.
>

​Ok​



> > ​
> >
> >
> > >     # 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?
>

I unnderstood the double negation the same way as yours.
---
*B. R.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20130821/9003ffa7/attachment-0001.html>


More information about the nginx mailing list