0

I'm using nginx (1.8.0) to serve content. I setup it up to respond stale (proxy_cache_use_stale) while updating and others. I noticed that it was responding with 404 responses while it was updating its cache, I thought only 2xx responses were served as stale.

How does an object (an HTTP response) enters, leave and gets updated as stale?

How can one mitigate this effect? (I mean to update the stale version from 404 to the latest valid 200)

Sample conf: nginx.conf

http {
    proxy_cache_use_stale error timeout updating invalid_header;
    proxy_cache_valid 404 10s;

    server {
      location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_cache_key $http_x_scheme$http_x_fe_host$uri;
        proxy_cache_lock on;
        proxy_cache_lock_timeout 5s;
      }
    }

    server {
      listen 8080;
    }

}
1

The issue was because I was sometimes generating a floating point for max-age HTTP header and then Nginx did these strange behaviors, like no updating a stale object.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.