nginx.conf:
events {
use epoll;
worker_connections 204800;
}
http{
client_header_buffer_size 4k;
large_client_header_buffers 4 4k;
open_file_cache max=102400 inactive=60s;
open_file_cache_valid 80s;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 8 64k;
fastcgi_temp_path /dev/shm/fastcgi_temp;
fastcgi_cache_path /dev/shm/fastcgi_cache levels=1:2 keys_zone=cfcache:10m inactive=50m max_size=256;
fastcgi_cache_key "$request_method://$host$request_uri";
fastcgi_cache_methods GET HEAD;
fastcgi_cache cfcache; //开启FastCGI缓存并且为其制定一个名称。
fastcgi_cache_valid 200 302 301 1h;
fastcgi_cache_valid any 5m; //为指定应答代码指定缓存时间,这里指定200 302 301应答缓存1小时,其余任何应答缓存5分钟
fastcgi_cache_min_uses 1; //缓存在fastcgi_cache_path内文件在inactive参数值时间内的最少使用次数,如上例,这里在50分钟内某文件1次也没有被使用,那么这个文件将被移除。
fastcgi_cache_use_stale error timeout invalid_header http_500;//对于error timeout invalid_header http_500等类型的应答内容不缓存
fastcgi_ignore_client_abort on;//忽略客户端终止请求
gzip on;
gzip_min_length 1k;
gzip_buffes 16 64k;
gzip_http_version 1.1;
gzip_comp_level 6;
gzip_types text/plain application/x-javascript text/css application/javascript text/javascript image/jpeg image/gif image/png application/xml application/json;
gzip_vary on;
gzip_disable "MSIE [1-6].(?!.*SV1)";
}