1

I need to configure cache for python(django) app on nginx. Everything works fine but from time to time I get blank page from cache. I dont see any errors in nginx and uwsgi logs. In normal situation i get HTTP/1.1 200 resposne 24615 bytes long from nginx but somethimes it is 20 bytes long.

HTTP/1.1 200   0.08 secs:   24615 bytes ==> /
HTTP/1.1 200   0.07 secs:   24615 bytes ==> /
HTTP/1.1 200   7.71 secs:   24615 bytes ==> /
HTTP/1.1 200   0.06 secs:      20 bytes ==> /
HTTP/1.1 200   0.06 secs:      20 bytes ==> /
HTTP/1.1 200   0.07 secs:      20 bytes ==> /
HTTP/1.1 200   7.79 secs:   24615 bytes ==> /
HTTP/1.1 200   0.07 secs:   24615 bytes ==> /

My cache config:

uwsgi_cache_path /var/cache/nginx_cache levels=1:2 keys_zone=my_cache:1m max_size=500m inactive=30m use_temp_path=off;
uwsgi_cache my_cache;
uwsgi_cache_key "$uri";
uwsgi_ignore_headers Cache-Control X-Accel-Expires Expires Vary Set-Cookie;
uwsgi_cache_valid 2s;

And ideas what is the reason of these 20 bytes responses?

1 Answers1

0

Looks like you cache HEAD response. According nginx docs (http://nginx.org/en/docs/http/ngx_http_uwsgi_module.html#uwsgi_cache_methods) HEAD method is always added to uwsgi_cache_methods.