title: add security headers in NGINX while using fastcgi caching
body: <p>I am using nginx with fastcgi cache. I want to use security headers on my site. I have already added add header field in my virtual host configurations but I can not get any headers unless I  disable add_header X-fastcgi cache $upstream cache status in my fastcgi_main.conf  file.
  virualhost file :</p>
  <pre><code>    }
     include /etc/nginx/bots.d/blockbots.conf;
     include /etc/nginx/bots.d/ddos.conf;
     include /etc/nginx/skip_cache.conf ;
     include /etc/nginx/purge_location.conf ;
     include /etc/nginx/gzip_location.conf ;
     include /etc/nginx/security_wp.conf;
          add_header Referrer-Policy 'origin';
          add_header &quot;X-Frame-Options: sameorigin&quot; always;
      location ~ \.php$ {
      include snippets/fastcgi-php.conf;
      fastcgi_pass  unix:/var/run/php/php7.3-fpm.sock;
      include &quot;/etc/nginx/customfastcgi&quot; ;
      proxy_connect_timeout 300;
      proxy_send_timeout 300;
      proxy_read_timeout 300;
      send_timeout 300;
  #    underscores_in_headers on;
  client_max_body_size 256M;
      include /etc/nginx/fastcgi_main.conf ;
      }
  
  }
  </code></pre>
  <p>FASTCGI_main.conf</p>
  <pre><code>        fastcgi_no_cache $skip_cache;
          fastcgi_cache phpcache;
          fastcgi_cache_valid 200 1m;
          fastcgi_cache_valid 301 1m;
          fastcgi_cache_valid 302 1m;
          fastcgi_cache_valid 307 1m;
          fastcgi_cache_valid 404 1m;
          fastcgi_cache_use_stale error timeout invalid_header http_500 http_503;
          fastcgi_cache_min_uses 1;
          fastcgi_cache_methods GET HEAD;
          fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
         add_header X-FastCGI-Cache $upstream_cache_status;
      ```
  
  RESULT:
  curl -I https://dev-kuhicbury.$domain
  HTTP/1.1 200 OK
  Server: nginx/1.10.3 (Ubuntu)
  Date: Fri, 09 Oct 2020 11:39:35 GMT
  Content-Type: text/html; charset=UTF-8
  Connection: keep-alive
  Vary: Accept-Encoding
  rel=&quot;https://api.w.org/&quot;
  X-FastCGI-Cache: HIT
  </code></pre>