这是我的配置文件:usr/local/nginx/sites-available/default
server {
listen 80;
server_name localhost;
location / {
root html;
index index.php index.html index.htm;
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html
{
root html;
}
# serve static files directly
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|swf)$ {
expires 30d;
}
但它不缓存静态文件,我该如何修复它?非常感谢
答案1
这对我有用:
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
root /var/www/u_1/public_html/;
}