Challenge - 5 Problems
Proxy Cache Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of proxy_cache_path directive with specific keys_zone
What is the effect of the following nginx configuration snippet on the cache zone named 'my_cache'?
Nginx
proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=my_cache:10m max_size=1g inactive=60m use_temp_path=off;
Attempts:
2 left
💡 Hint
Focus on the meaning of each parameter: keys_zone size, levels, max_size, inactive, and use_temp_path.
✗ Incorrect
The keys_zone parameter defines the shared memory size for cache keys. Levels define the directory structure for cache files. Max_size limits total cache size. Inactive defines how long cached items stay without access before removal. Use_temp_path=off disables temporary file usage during caching.
🧠 Conceptual
intermediate1:30remaining
Understanding cache directory levels in proxy_cache_path
Why does nginx use multiple levels of directories (e.g., levels=1:2) in the proxy_cache_path configuration?
Attempts:
2 left
💡 Hint
Think about how filesystems handle many files in one folder.
✗ Incorrect
Filesystems slow down when too many files are in one directory. Using multiple directory levels spreads files out, making access faster and more efficient.
❓ Troubleshoot
advanced2:30remaining
Troubleshooting cache not storing files
Given this proxy_cache_path configuration:
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=cache_zone:20m max_size=500m inactive=30m;
And this proxy_cache usage:
proxy_cache cache_zone;
Why might nginx not store any cache files in /var/cache/nginx?
Attempts:
2 left
💡 Hint
Check file system permissions for the cache directory.
✗ Incorrect
If nginx cannot write to the cache directory due to permission issues, it will not store cache files. The keys_zone size and max_size do not prevent caching by themselves. Inactive time controls expiration but does not stop caching initially.
✅ Best Practice
advanced2:00remaining
Best practice for proxy_cache_path keys_zone size
What is the recommended approach when setting the keys_zone size in proxy_cache_path for a high-traffic nginx server?
Attempts:
2 left
💡 Hint
Think about how nginx uses shared memory for cache keys.
✗ Incorrect
A larger keys_zone allows nginx to keep more cache keys in fast shared memory, reducing disk access and improving performance. Too small keys_zone causes frequent disk lookups, slowing caching.
🔀 Workflow
expert3:00remaining
Correct order to enable proxy caching with custom cache path
Arrange the steps in the correct order to enable proxy caching in nginx with a custom cache directory '/custom/cache' and cache zone 'custom_zone'.
Attempts:
2 left
💡 Hint
Think about preparation before configuration and applying changes last.
✗ Incorrect
First, create and set permissions on the cache directory (step 4). Then define proxy_cache_path (step 1). Next, enable proxy_cache in server/location block (step 2). Finally, reload nginx to apply changes (step 3).