Varnish 5.0.0 正式版发布,开源HTTP加速器
比如配置针对PHP-FPM这些FastCGI服务的缓存fastcgi_cache,PHP返回的内容会被Nginx缓存成静态文件,无需任何PHP逻辑干预,最高性能静态缓存没有之一! http {...
#配置fastcgi_cache缓存 http://wiki.nginx.org/HttpFcgiModule
#levels=1:2 表示缓存目录的第一级目录是1个字符,第二级目录是2个字符.
#keys_zone=EXAMPLE:32m 表示这个zone名称为EXAMPLE,分配的内存大小为32MB.
#inactive=1d 表示这个zone中的缓存文件如果在1天内都没有被访问,那么文件会被cache manager进程删除掉.
#max_size=2g 表示这个zone的硬盘容量为2GB.
fastcgi_temp_path /png/ngx_fcgi_tmp;
fastcgi_cache_path /png/ngx_fcgi_cache levels=1:2 keys_zone=EXAMPLE:32m inactive=1d max_size=2g;
fastcgi_cache_key $request_method://$host$request_uri;
...
server {
...
location ~ \.php$ {
...
#配置fastcgi_cache缓存
include fastcgi.conf;
#用哪个缓存空间
fastcgi_cache EXAMPLE;
#定义哪些http头要缓存
fastcgi_cache_valid 200 302 1h;
fastcgi_cache_valid 301 1d;
fastcgi_cache_valid any 1m;
#定义哪些情况下用过期缓存
fastcgi_cache_use_stale error timeout invalid_header http_500;
...
}
...
}
}
页:
[1]