caching - Nginx cache bypass by custom response header -


i want implement custom nginx cache control method scripts, using custom header: "do-cache". used in http block of nginx:

map $sent_http_do_cache $nocache {         public 0;         default 1; } 

and in server block of nginx:

fastcgi_cache_bypass $nocache; fastcgi_no_cache $nocache; 

so, do-cache: public, nginx should cache response. otherwise not.

but configuration not working. debuging logs values of $sent_http_do_cache , $nocache right ones, until used in server block of nginx. if using them in server block (fastcgi_cache_bypass $nocache, or simple set $a $nocache), $nocache variable got "1" value, , $sent_http_do_cache - "-".

is other way of managing cache of nginx based on custom header in response?


Comments