A note for myself to exaplain fastcgi_cache_path, levels, keys_zone, max_size, inactive, use_temp_path
fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=WPCACHE:100M max_size=10G inactive=1d use_temp_path=off; fastcgi_cache_key "$scheme$request_method$host$request_uri"; fastcgi_cache_use_stale error timeout invalid_header http_500;
As documentation said, nginx will keep all active keys and information about data are stored in a shared memory zone, whose
size are configured by the keys_zone parameter. As a matter of completeness, lets break down per part
/var/cache/nginxis the place where the actual cache stored. Inside the folder, cache file was binary file but you can easily spot the html tag inside it.
levels=1:2is levels parameter sets the number of subdirectory levels in cache.
keys_zone=WPCache:100mwas defining shared memory zone named WPCache with maximum size 100 MB. It holds all active keys and metadata of the cache. So, whenever nginx checks if a page was cached, it consults the shared memory zone first, then seek the location of actual cache in
/var/cache/nginxif cache exist.
max_sizewas maximum size of cache e.g. files size on
inactive=1dspecify maximum inactive time cache can be stored. Cached data that are not accessed during the time specified by the
inactiveparameter get removed from the cache regardless of their freshness.
use_temp_pathturn off the temp path, if not it will use