background image

 

fastcgi_cache 缓存设置

代码如下:

#定义缓存存放的文件夹

fastcgi_cache_path /tt/cache levels=1:2 keys_zone=NAME:2880m inactive=2d max_size=10G;

#定义缓存不同的 url 请求

fastcgi_cache_key "$scheme$request_method$host$uri$arg_filename$arg_x$arg_y";

server {

listen 8080;

server_name www.example .com;

location / {

root /www;

index index.html index.htm index.php;

}

location ~ (|.php)$ {

root /www;

fastcgi_pass 127.0.0.1:9000;

fastcgi_cache NAME;

fastcgi_cache_valid 200 48h;

fastcgi_cache_min_uses 1;

fastcgi_cache_use_stale error timeout invalid_header http_500;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

include fastcgi.conf;

#设置缓存的过程中发现无法获取 cookie,经查需要定义这句话

fastcgi_pass_header Set-Cookie;

}

log_format access '$remote_addr - $remote_user [$time_local] "$request" '

'$status $body_bytes_sent "$http_referer" '