nginx怎么加expire头

来源:互联网 发布:时时彩平刷软件 编辑:程序博客网 时间:2024/04/27 17:48

     nginx怎么对网站的图片、js和css添加过期头呢?

     在nginx配置文件server配置下,添加如下配置:

 

  server {

 

 location ~* ^.+/.(jpg|jpeg|gif|png|bmp)$ {
        access_log /data/logs/image.log;
        root '/usr/opt/nginx/html/www1';
        expires 30d;
        break;
    }

 

    location ~* ^.+/.(js|css)?${
       access_log /data/logs/jsandcss.log;   
       root '/usr/opt/nginx/html/www1';
       expires 30d;
    }

    }

 

     keyword:nginx expire

原创粉丝点击