开启Nginx提供预压缩文件
server {
listen 80;
listen 443 ssl http2;
server_name test.com;
index index.php index.html index.htm default.php default.htm default.html;
root /www/wwwroot/test.com;
# ...省略了SSL和其他配置...
# 开启gzip_static
gzip_static on;
# ...省略了其余配置...
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
error_log /dev/null;
access_log /dev/null;
}
location ~ .*\.(js|css)?$ {
expires 12h;
error_log /dev/null;
access_log /dev/null;
# 也可以在特定的location块中开启gzip_static
# gzip_static on;
}
# ...省略了日志和其他配置...
}
License:
私有