title: Nginx proxy cache always x-cache-status: MISS
body: <p>My nginx cache does not work. I have followed some answers by still not work. Could anybody help me?</p>
  
  <p>I have ignored the headers: cache-control, Set-Cookies, but not work.</p>
  
  <p><strong>My cached url is</strong>: 
  <a href="https://p.rmiao.top/proxy/bing/HPImageArchive.aspx?format=js&amp;idx=0&amp;n=2" rel="nofollow noreferrer">https://p.rmiao.top/proxy/bing/HPImageArchive.aspx?format=js&amp;idx=0&amp;n=2</a></p>
  
  <p><strong>My Request Headers</strong>:</p>
  
  <pre><code>:authority: p.rmiao.top
  :method: GET
  :path: /proxy/bing/HPImageArchive.aspx?format=js&amp;idx=0&amp;n=2
  :scheme: https
  accept: application/json, text/javascript, */*; q=0.01
  accept-encoding: gzip, deflate, br
  accept-language: zh-CN,zh;q=0.9,zh-TW;q=0.8
  cache-control: no-cache
  origin: https://www.cnblogs.com
  pragma: no-cache
  referer: https://www.cnblogs.com/woshimrf/p/java-list-distinct.html
  user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) 
  AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
  </code></pre>
  
  <p><strong>My Response Headers</strong>:</p>
  
  <pre><code>access-control-allow-credentials: true
  access-control-allow-headers: Cache-Control, reqid, nid, host, x- real-ip, x-forwarded-ip, event-type, event-id, accept, content-type
  access-control-allow-methods: GET, POST, OPTIONS, DELETE
  access-control-allow-origin: https://www.cnblogs.com
  access-control-max-age: 2592000
  cache-control: public, max-age=604800
  content-encoding: gzip
  content-length: 771
  content-type: application/json; charset=utf-8
  date: Mon, 16 Apr 2018 09:13:24 GMT
  server: nginx/1.12.2
  status: 200
  x-cache-status: MISS
  </code></pre>
  
  <p><strong>My nginx configure</strong>:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>proxy_cache_path /tmp/nginx/cache levels=1:2 keys_zone=bing_cache:10m max_size=1g inactive=48h use_temp_path=off;
  
  server {
      listen 443 ssl http2;
      server_name  p.rmiao.top;
  
      location ^~/proxy/bing/ {
  
          proxy_cache bing_cache;
          proxy_ignore_headers   vary X-Accel-Expires Expires Cache-Control  Set-Cookie;
          proxy_hide_header      Set-Cookie;
          proxy_hide_header      Cache-Control;
          proxy_hide_header      p3p;
          proxy_hide_header      server;
          proxy_hide_header      date;
          proxy_hide_header      x-msedge-ref;
          proxy_hide_header      vary;
          add_header X-Cache-Status $upstream_cache_status;
  
          valid_referers none blocked *.cnblogs.com server_names ~\.rmiao\.;
          if ($invalid_referer) {
           return 403;
          }
  
          add_header 'Access-Control-Allow-Origin' "$http_origin";
          add_header 'Access-Control-Allow-Credentials' "true";
          add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, DELETE';
          add_header 'Access-Control-Allow-Headers' 'Cache-Control, reqid, nid, host, x-real-ip, x-forwarded-ip, event-type, event-id, accept, content-type';
          add_header 'Access-Control-Max-Age' 2592000;
          add_header 'Cache-Control' "public, max-age=604800";
  
          if ( $request_method = "OPTIONS" ) {
            return 204;
          }
  
          rewrite ^/proxy/bing/(.*)$ /$1 break;
          proxy_pass https://cn.bing.com;
      }
  
      #error_page  404              /404.html;
  
      # redirect server error pages to the static page /50x.html
      #
      error_page   500 502 503 504  /50x.html;
      location = /50x.html {
          root   html;
      }
  
  
      ssl_certificate /etc/letsencrypt/live/p.rmiao.top/fullchain.pem; # managed by Certbot
      ssl_certificate_key /etc/letsencrypt/live/p.rmiao.top/privkey.pem; # managed by Certbot
  }</code></pre>
  </div>
  </div>
  </p>