Welcome! Log In Create A New Profile

Advanced

Re: nginx with proxy_cache_use_stale not returning from cache when connection refused

Ruslan Ermilov
December 11, 2014 03:14AM
On Wed, Dec 10, 2014 at 11:45:26AM -0500, new299 wrote:
> Hi,
>
> I'm using nginx as a reverse proxy, but I can't get nginx to serve requests
> from its cache when the upstream server is refusing connections. I
> understood that "proxy_cache_use_stale error" should allow me to do this,
> but it doesn't seem to work for me. Have I perhaps misunderstood something?
>
> My complete nginx.conf looks like this:
>
> user www-data;
> worker_processes 4;
> pid /run/nginx.pid;
>
> events {
> worker_connections 768;
> # multi_accept on;
> }
>
> http {
> upstream localsvr {
> server localhost:8080;
> }
>
> proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=one:8m
> max_size=5000m inactive=300m;
> access_log /var/log/nginx/access.log;
> error_log /var/log/nginx/error.log;
> server {
> keepalive_timeout 65;
> types_hash_max_size 2048;
> proxy_buffering on;
>
> default_type application/octet-stream;
>
> gzip on;
> gzip_disable "msie6";
> listen 80;
> proxy_cache one;
> proxy_cache_min_uses 100;
> proxy_set_header Host $host;
> location / {
> proxy_pass http://localsvr;
> proxy_cache_use_stale error;
> proxy_next_upstream error;
> proxy_redirect off;
> }
> }
> }

Your config doesn't have any http://nginx.org/r/proxy_cache_valid
directives. If this is intentional, then your responses should
carry caching information themselves (X-Accel-Expires, Expires,
Cache-Control, Set-Cookie, Vary, see the link above for details)
and otherwise qualify to be cached.

Also, "proxy_cache_min_uses 100" in your config instructs to cache
a response only after it was requested 100 times.

Please first make sure your responses actually get cached by
looking into /data/nginx/cache.

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

nginx with proxy_cache_use_stale not returning from cache when connection refused

new299 December 10, 2014 11:45AM

Re: nginx with proxy_cache_use_stale not returning from cache when connection refused

Maxim Dounin December 10, 2014 12:22PM

Re: nginx with proxy_cache_use_stale not returning from cache when connection refused

new299 December 10, 2014 10:00PM

Re: nginx with proxy_cache_use_stale not returning from cache when connection refused

jurerickporras December 15, 2014 12:28PM

Re: nginx with proxy_cache_use_stale not returning from cache when connection refused

Maxim Dounin December 11, 2014 09:42AM

Re: nginx with proxy_cache_use_stale not returning from cache when connection refused

Maxim Dounin December 15, 2014 01:12PM

Re: nginx with proxy_cache_use_stale not returning from cache when connection refused

Ruslan Ermilov December 11, 2014 03:14AM

Re: nginx with proxy_cache_use_stale not returning from cache when connection refused

new299 December 11, 2014 10:14AM

Re: nginx with proxy_cache_use_stale not returning from cache when connection refused

new299 December 11, 2014 10:25AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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