0

I have an nginx server proxying and caching requests to django backend. The headers when i make a curl to django gunicorn request are the following:

HTTP/1.1 200 OK
Server: gunicorn/19.9.0
Date: Mon, 05 Aug 2019 17:30:55 GMT
Connection: close
Vary: Cookie, Accept-Language
Content-Type: text/html; charset=utf-8
Content-Language: en
Set-Cookie: csrftoken=AV42uqHK4znT5iGHnr4dzaKNUaQmKjw0; expires=Mon, 03-Aug-2020 17:30:55 GMT; Max-Age=31449600; Path=/

I currently ignore the following headers:

proxy_ignore_headers X-Accel-Redirect;
proxy_ignore_headers X-Accel-Expires;
proxy_ignore_headers X-Accel-Limit-Rate;
proxy_ignore_headers X-Accel-Buffering;
proxy_ignore_headers X-Accel-Charset;
proxy_ignore_headers Expires;
proxy_ignore_headers Cache-Control;
proxy_ignore_headers Set-Cookie;
proxy_ignore_headers Vary;

And for cache i have the following configurations:

proxy_buffering on;
proxy_cache STATIC;
proxy_cache_valid any 5m;
add_header X-Proxy-Cache-Status $upstream_cache_status;
add_header X-Proxy-Cached-Date $upstream_http_date;

What is happening now is that when i make requests to the server i get the cached content for one minute aproximately and then i get a MISS. I dont care about user sessions so ignoring set-cookie is not a problem.

Where the problem could be? How can i debug this?

Thanks!

  • What’s STATIC zone definition? – Alexey Ten Aug 6 at 5:21
-1

If everyone have the same problem, my problem was that i was mixing the django app cache folder with the nginx server cache folder. So django was randomly deleting nginx cache files.

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.