Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm new to Nginx. My nginx cache setting in the nginx.conf

fastcgi_cache_path  /dev/shm levels=1:2 keys_zone=my-cache:100m inactive=7d;

What is it means? the level, 100m and inactive=7d ?

Thank's in advaced.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

From the Nginx conf page: http://wiki.nginx.org/HttpFastcgiModule#fastcgi_cache_path

"Level parameter sets number and width of the names of subdirectories used to store caching files."

In other words, if you set your cache to /dev/shm levels=1:2 and you go into /dev/shm you will see tons of folders whose name is 1 character long. Underneath each of those folders, you will see more folders whose names are 2 characters long. Underneath each of those folders will be the actual cached data.

Regarding keys_zone and inactive:

http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_cache_path

"In addition, all active keys and information about data are stored in a shared memory zone, whose name and size are configured by the keys_zone parameter. Cached data that are not accessed during the time specified by the inactive parameter get removed from the cache regardless of their freshness. By default, inactive is set to 10 minutes."

The keys_zone parameter essentially acts as an "address book" to all the files in the cache. The name parameter simply names the keys_zone area for this nginx instance and the size parameter increases/decreases the total size available to be filled up with keys. In other words, the larger your cache(read: inactive set high) and the higher your traffic, the larger you want your keys_zone to be if you want to be able to cache everything.

share|improve this answer
    
Ok, i got the level key keys_zone name (my-cache) and inactive, but what the 100m (100 minutes) mean? –  imastar Jan 26 '13 at 18:50
    
It's not minutes, it's size. It means that the keys_zone file will store keys up until it reaches it's maximum size of 100MB –  Marcos Velazquez Jan 26 '13 at 19:08
    
I see... Thank you. –  imastar Jan 26 '13 at 20:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.