Forum: NGINX proxy_cache_valid for zero seconds

Posted by shmapty (Guest)
on 2012-11-14 22:10
(Received via mailing list)
Greetings,

I am trying to configure nginx proxy_cache so that it stores a cached 
copy
of a HTTP response, but serves from cache *only* under the conditions
defined by proxy_cache_use_stale.

I have tried something like this without success:

    proxy_cache_valid           200 204 301 302 0s;
    proxy_cache_use_stale       error timeout updating invalid_header
http_500 http_502 http_504;

"0s" appears to avoid caching completely.  "1s" stores a cached copy, 
but
presumably serves from cache for one second.  I am trying to serve from
cache only when the upstream errs.

Thank you

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,232815,232815#msg-232815
Posted by shmapty (Guest)
on 2012-11-20 21:12
(Received via mailing list)
Put another way -- can I store/cache all content from the proxied 
upstream
(up to the limits defined in proxy_cache_path), but serve from the cache
only when the proxied upstream fails (e.g. timeout, error)?

We have content that should be dynamic, and hence every request should 
be
transparently proxied.  However, I want to protect against the situation
when the upstream is down or having trouble.  Serving a stale response
(though normally undesirable), is better than returning an error.

Thank you

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,232815,233027#msg-233027
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.