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