STALE responses taking as much as MISS responses

Reinis Rozitis r at roze.lv
Mon Feb 11 19:50:19 UTC 2019


> On my logs I can see that HIT's are very fast but STALEs take as much as MISS
> while I believe they should take as much as HITs.
> 
> Is there something I can do to improve this ? Are the stale responses a true
> "stale-while-revalidate" response ?or are they waiting for the response from the
> origin server ?

IMO the stale responses can't be as fast as HIT even theoretically (except maybe in 'updating' state with proxy_cache_background_update enabled) since they happen when the cache object has expired and nginx tries to get a new version from backend but for some reason can't get an updated response from the upstream (all the proxy_cache_use_stale states).

I would try to identify why the stales actually happen - is it because the backend fails or there are multiple parallel requests to the same url and something like proxy_cache_lock is also defined.

To speed up the response you might want to check the proxy_*_timeout directives as the defaults are quite high (60sec) and for example proxy_read_timeout is between reads so depending on the object size in case of a slow backend might take even more time.

rr



More information about the nginx mailing list