性能优化-expires缓存实现性能优化
在虚拟主机配置文件中配置
[root@web01 conf]# cat extra/www.conf server { listen 80; server_name www.abc.com; rewrite ^(.*)$ https://$host$1 permanent; } server { listen 443; server_name www.abc.com; #https证书 ssl on; ssl_certificate /application/nginx/conf/key/server.crt; ssl_certificate_key /application/nginx/conf/key/server.key; #访问日志 access_log logs/access_www.log main buffer=32k flush=5s; location / { root html/www; index index.php index.html index.htm; } #隐藏版本号 server_tokens on; #客户端对静态内容缓存 添加的 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30y; root html/www; } location ~ .*\.(js|css)?$ { expires 30d; root html/www; } #php解析 location ~ .*\.(php|php5)?$ { root html/www; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; #FastCGI 相关参数调优 #fastcgi_cache ngx_fcgi_cache; fastcgi_cache_valid 200 302 1h; fastcgi_cache_valid 301 1d; fastcgi_cache_valid any 1m; fastcgi_cache_min_uses 1; fastcgi_cache_use_stale error timeout invalid_header http_500; fastcgi_cache_key http://$host$request_uri; } }
转载于:https://blog.51cto.com/13673885/2300267