「Linux/nginx/パフォーマンス向上」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→ブラウザのキャッシュを活用する方法) |
|||
| 行23: | 行23: | ||
==ブラウザのキャッシュを活用する方法== | ==ブラウザのキャッシュを活用する方法== | ||
| − | location ~* \.( | + | location ~* \.(txt|xml)$ { |
fastcgi_pass_header "X-Accel-Expires"; | fastcgi_pass_header "X-Accel-Expires"; | ||
| − | expires | + | expires 2d; |
| + | } | ||
| + | location ~* \.(jpg|gif|png|swf|css|js|inc|ico|pdf|flv|gz)$ { | ||
| + | fastcgi_pass_header "X-Accel-Expires"; | ||
| + | expires 365d; | ||
| + | } | ||
| + | location ~* \.(html|htm)$ { | ||
| + | fastcgi_pass_header "X-Accel-Expires"; | ||
| + | expires 1d; | ||
} | } | ||
2015年5月21日 (木) 05:53時点における版
静的ファイル圧縮
vi /etc/nginx/conf.d/sample1.localhost.conf
http {
gzip on;
gzip_http_version 1.0;
gzip_types text/plain
text/xml
text/css
application/xml
application/xhtml+xml
application/rss+xml
application/atom_xml
application/javascript
application/x-javascript
application/x-httpd-php;
gzip_disable "MSIE [1-6]\.";
gzip_disable "Mozilla/4";
gzip_comp_level 1;
gzip_buffers 4 8k;
gzip_min_length 1100;
このさき略
}
ブラウザのキャッシュを活用する方法
location ~* \.(txt|xml)$ {
fastcgi_pass_header "X-Accel-Expires";
expires 2d;
}
location ~* \.(jpg|gif|png|swf|css|js|inc|ico|pdf|flv|gz)$ {
fastcgi_pass_header "X-Accel-Expires";
expires 365d;
}
location ~* \.(html|htm)$ {
fastcgi_pass_header "X-Accel-Expires";
expires 1d;
}
参照
http://www.mk-mode.com/octopress/2013/01/18/nginx-gzip-compress/
