The Forum avatar is dynamic, for example: Http://xxx.xxx.xxx/avatar.php?uid=xxx&size=big
Each user's avatar file has big, middle, small three, and in different scenes to call different sizes of Avatar pictures, such as posts, personal settings, avatar editing, landing and so on, virtually increased the work pressure between Nginx and PHP, If you can cache this parsing result, it will reduce the communication pressure between Nginx and PHP, which will reduce the system CPU utilization.
To test the Nginx cache function, configure the following:
HTTP domain Additions
Fastcgi_cache_path/xxxcache levels=1:2 keys_zone=cgicache:30m inactive=1d max_size=10g;
Server domain Additions
Location ~* ^/avatar.php?. *$ {
Add_header X-CACHE-CFC "$upstream _cache_status-$upstream _response_time";
Fastcgi_temp_path/xxxtemp;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Include Fastcgi_params;
Fastcgi_cache Cgicache;
Fastcgi_cache_valid 301 302 1h;
Fastcgi_cache_min_uses 1;
Fastcgi_cache_use_stale error timeout Invalid_header http_500;
Fastcgi_cache_key $host $request_uri;
}
By verifying that the cache file is generated successfully, the HTTP request is changed to miss, hit, and so on.
This article is from the "Bodhi" blog, so be sure to keep this source http://zhangxingnan.blog.51cto.com/3241217/1619053
Discuz Avatar Program parsing result Cache