4

I am trying to cache my requests in nginx. I have connected my django server as upstream. Now, I am trying to cache my requests.

proxy_cache_path /var/cache/nginx/ keys_zone=one:10m;

location / {
            proxy_cache one;
            proxy_cache_valid 200 302 10m; 
            proxy_no_cache $cookie_nocache $arg_nocache$arg_comment;
            proxy_cache_bypass $cookie_nocache $arg_nocache$arg_comment;
            proxy_cache_use_stale error http_502;
            proxy_pass http://127.0.0.1:8000;

}                                

Everything is working, but now I have added

proxy_cache_use_stale error http_502;

this statement.

It means that it should serve cached content even in case of error, 502 response code. To test it, I stopped my django server, and it should serve these requests now even when the django server is off.

But it is again sending 502 bad gateway.

Am I getting anything wrong here ? How do I get to know that whether my request has been cached or not ?

Luv33preet
  • 206
  • 1
  • 11

0 Answers0