我已经设置了一个指令caching到nginx中的memdisk:
fastcgi_cache_path /dev/shm/nginx levels=1:2 keys_zone=WPCACHE:2048m inactive=480m; fastcgi_cache_key "$scheme$request_method$host$request_uri"; server { #snip other locations... # Pass all .php files onto a php-fpm/php-fcgi server. location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; include fastcgi_params; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass php; fastcgi_cache WPCACHE; fastcgi_cache_valid 200 480m; add_header X-Cache $upstream_cache_status; fastcgi_cache_methods GET HEAD; fastcgi_cache_bypass $skip_cache; fastcgi_no_cache $skip_cache; #more_clear_headers Server; more_clear_headers "Pragma"; add_header Z_LOCATION "PHP MAIN"; add_header URI $uri; # DEBUG } }
我知道这应该限制高速caching的大小为2GB为480分钟 ,但现在在2.8GB以上这个限制 – 任何想法我做错了请吗?
root@www1:/dev/shm/nginx# du -sch * 182M 0 183M 1 177M 2 174M 3 177M 4 172M 5 172M 6 167M 7 174M 8 172M 9 168M a 171M b 174M c 177M d 172M e 179M f 2.8G total
fastcgi_cache_path指令的keys_zone参数指定存储caching键的内存区域。 其大小间接限制了caching可以存储的项目数量(1兆字节〜8K项目),但不是caching的磁盘大小。
要限制磁盘大小,请使用max_size参数:
fastcgi_cache_path ... max_size=2048m;
有关更多详细信息,请参阅fastcgi_cache_path文档 。