Nginx 过期时间

客户端(浏览器)访问服务器上的资源后,会缓存在浏览器中,对于一些经常变更的静态资源,我们可以设置缓存时间,也就是设置静态资源的过期时间

[root@localhost ~]$ cat /usr/local/nginx/conf/vhost/test.com.conf 
server {
    listen 80;
    server_name www.test.com;
    index index.html index.html index.php;
    root /data/www;
  
    location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$ {
        expires 7d;
    }

location ~ .*.(js|css)$ {
expires 12h;
} }

    

原文地址:https://www.cnblogs.com/pzk7788/p/10333316.html