title: Nginx, how to remove headers before caching the request
body: <p>I need to remove the headers received from the upstream proxy before storing the request into the nginx cache.</p>
  
  <p>With the following configuration I can see how the headers defined for clear are not deliver to the client, but are stored in the cache path, if I open one of the files located there I can see all.</p>
  
  <pre><code>proxy_cache_path  /var/cache levels=1:2  keys_zone=STATIC:1m inactive=1y max_size=50G;
  server {
  
          listen localhost;
          server_name myserver;
  
          location / {
  
                  more_clear_headers 'Last-Modified';
                  more_clear_headers 'Cache-Control';
                  more_clear_headers 'Expires';
                  more_clear_headers 'X-Powered-By';
                  more_clear_headers 'X-AspNet-Version';
                  more_clear_headers 'X-Powered-By';
                  more_set_headers -s 200 'Cache-Control:  max-age=31557600';
  
                  proxy_pass http://IP;
  
                  proxy_set_header       Host example.com;
                  proxy_cache            STATIC;
                  proxy_cache_valid      200 301 302 1y;
                  proxy_cache_use_stale  error timeout invalid_header updating http_500 http_502 http_503 http_504;
                  proxy_cache_key $uri;
  
                  add_header X-Proxy-Cache $upstream_cache_status;
  
          }
  }
  </code></pre>