未指定Nginx浏览器缓存过期

时间:2016-04-04 09:37:19

标签: caching nginx browser config browser-cache

关于nginx和服务器配置,我是新手。

我似乎无法设置浏览器缓存过期。我不知道自己做错了什么。当我在Gtmetrix上测试它时,说"到期未指定"。我希望你能帮助我。

# Virtual host file starts here

server {
  listen 80;
  access_log /var/log/nginx/access.upholsterycleanigs.com.aulog;
  error_log /var/log/nginx/error.upholsterycleanings.com.au.log;
  server_name upholsterycleanings.com.au www.upholsterycleanings.com.au;
  root /home/upholsterycleanings/public_html;
  location / {
    location ~.*\.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|html|htm|txt|js|css|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso|woff|ttf|svg|eot)$ {
      expires 30d; #Comment this out if you are using the apache backend cache-control/expires headers.
      try_files \$uri \@backend;
    }
    error_page 405 = \@backend;
    error_page 500 = \@custom;
    add_header X-Cache "HIT from Backend";
    proxy_pass http://172.31.37.201:8181;
    include proxy.inc;
  }
  location \@backend {
    internal;
    proxy_pass http://172.31.37.201:8181;
    include proxy.inc;
  }
  location \@custom {
    internal;
    proxy_pass http://172.31.37.201:8181;
    include proxy.inc;
  }
  location ~ .*\.(php|jsp|cgi|pl|py)?\$ {
    proxy_pass http://172.31.37.201:8181;
    include proxy.inc;
  }
  location ~ /\.ht {
    deny all;
  }
}

# Virtual host file ends here

谢谢!

0 个答案:

没有答案