0
0
Nginxdevops~20 mins

Open file cache in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Open File Cache Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the purpose of the open_file_cache directive in nginx?

nginx uses the open_file_cache directive to improve performance. What does it specifically cache?

AIt caches DNS lookups to speed up domain name resolution.
BIt caches the entire content of files in memory for faster delivery.
CIt caches open file descriptors to reduce file open/close operations.
DIt caches HTTP headers to reduce processing time.
Attempts:
2 left
💡 Hint

Think about what happens when nginx serves static files repeatedly.

Configuration
intermediate
2:00remaining
Which configuration snippet correctly enables open_file_cache with 100 max cached files and 60 seconds inactive timeout?

Choose the correct nginx configuration to enable open_file_cache with a maximum of 100 cached files and an inactive timeout of 60 seconds.

Aopen_file_cache max_files=100 inactive_timeout=60;
Bopen_file_cache 100 60s;
Copen_file_cache max=60 inactive=100s;
Dopen_file_cache max=100 inactive=60s;
Attempts:
2 left
💡 Hint

Check the correct parameter names and syntax for open_file_cache.

💻 Command Output
advanced
2:00remaining
What error will nginx report if open_file_cache is set with an invalid time unit?

Given this configuration snippet:

open_file_cache max=50 inactive=5x;

What error message will nginx show when testing this config?

Anginx: [emerg] invalid time value "5x" in /etc/nginx/nginx.conf:10
Bnginx: [warn] unknown directive "open_file_cache" in /etc/nginx/nginx.conf:10
Cnginx: [error] failed to start due to syntax error in open_file_cache
Dnginx: configuration file /etc/nginx/nginx.conf test is successful
Attempts:
2 left
💡 Hint

Look for errors related to invalid time formats in nginx.

Troubleshoot
advanced
2:00remaining
Why might enabling open_file_cache not improve performance as expected?

You enabled open_file_cache with proper settings, but nginx performance did not improve. Which reason is most likely?

AThe <code>open_file_cache_valid</code> directive is set too low, causing frequent cache invalidation.
BThe server has too much free memory, so caching is disabled automatically.
CThe <code>open_file_cache</code> directive only works for dynamic content, not static files.
DThe <code>open_file_cache_min_uses</code> is set to 0, so files are never cached.
Attempts:
2 left
💡 Hint

Think about how cache validity affects caching benefits.

Best Practice
expert
2:00remaining
What is the recommended way to configure open_file_cache for a high-traffic static file server?

For a high-traffic nginx server serving mostly static files, which configuration is best practice for open_file_cache?

Aopen_file_cache max=100 inactive=30s; open_file_cache_valid 5s; open_file_cache_min_uses 1;
Bopen_file_cache max=10000 inactive=120s; open_file_cache_valid 60s; open_file_cache_min_uses 2;
Copen_file_cache max=500 inactive=10s; open_file_cache_valid 1s; open_file_cache_min_uses 0;
Dopen_file_cache max=50 inactive=300s; open_file_cache_valid 300s; open_file_cache_min_uses 10;
Attempts:
2 left
💡 Hint

Consider cache size, validity, and minimum uses for effective caching.