Home > Enterprise >  In Nginx how to assign cache control response header
In Nginx how to assign cache control response header

Time:01-31

Based on the response code I would like to set the cache control header in map if it is 301 the set "no-cache, no-store, must-revalidate" else default set the value which came with the response. Is there a response_cache_controle or similar command

map $status $bb2_cache_control_header {
    301    "no-cache, no-store, must-revalidate";
    default $response_cache_control";
}

CodePudding user response:

Use add_header directive as follow:

add_header Cache-Control $bb2_cache_control_header;
  • Related