What is the purpose of the open_file_cache directive in nginx?
The open_file_cache directive caches information about open files to reduce file system lookups and improve performance.
Click to reveal answer
intermediate
Which parameters are commonly set with open_file_cache?
Common parameters include max (maximum number of cached files), inactive (time after which cached items are removed if not used), and min_uses (minimum number of uses before caching).
Click to reveal answer
intermediate
What does the open_file_cache_valid directive control?
It sets how often nginx checks if cached file information is still valid, by specifying a time interval.
Click to reveal answer
beginner
How does enabling open_file_cache affect nginx performance?
It reduces the number of file system calls, which lowers latency and CPU usage, making nginx serve files faster.
Click to reveal answer
beginner
What happens if open_file_cache is not used in a high-traffic nginx server?
Nginx will perform more frequent file system lookups, increasing CPU load and slowing down response times.
Click to reveal answer
What does the open_file_cache directive do in nginx?
ACaches information about open files to reduce file system lookups
BCaches HTTP responses for faster delivery
CLimits the number of open connections
DManages user sessions
✗ Incorrect
The open_file_cache directive caches file info to reduce file system calls.
Which parameter sets the maximum number of cached files in open_file_cache?
Ainactive
Bmax
Cmin_uses
Dvalid
✗ Incorrect
The max parameter defines the maximum number of cached files.
What does open_file_cache_valid control?
AMaximum cache size
BTimeout for client connections
CMinimum uses before caching
DHow long cached file info is considered valid before rechecking
✗ Incorrect
open_file_cache_valid sets the interval for cache validation.
If open_file_cache is disabled, what is a likely effect?
AMore cached files
BFaster file serving
CMore file system lookups and higher CPU usage
DReduced memory usage
✗ Incorrect
Without caching, nginx does more file system calls, increasing CPU load.
Which directive controls how many times a file must be used before caching with open_file_cache?
Amin_uses
Binactive
Cmax
Dvalid
✗ Incorrect
min_uses sets the minimum number of uses before caching a file.
Explain how the open_file_cache directive improves nginx performance.
Think about how caching avoids repeated work.
You got /4 concepts.
Describe the key parameters of open_file_cache and their roles.
Focus on what controls cache size, duration, and validation.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of the open_file_cache directive in nginx?
easy
A. To limit the number of open connections to clients
B. To store file information in memory to speed up file access
C. To cache HTTP responses from upstream servers
D. To compress files before sending them to clients
Solution
Step 1: Understand the role of open_file_cache
The open_file_cache directive caches file metadata like file descriptors and attributes.
Step 2: Identify its effect on performance
By caching file info, nginx reduces disk access and speeds up serving static files.
Final Answer:
To store file information in memory to speed up file access -> Option B
Quick Check:
open_file_cache purpose = cache file info [OK]
Hint: Remember: open_file_cache speeds file access by caching file info [OK]
Common Mistakes:
Confusing open_file_cache with HTTP response caching
Thinking it limits client connections
Assuming it compresses files
2. Which of the following is the correct syntax to enable open file cache with 1000 max cached files and 60 seconds inactive timeout?
easy
A. open_file_cache max=1000 inactive=60;
B. open_file_cache 1000 60s;
C. open_file_cache max=1000 inactive=60s;
D. open_file_cache max=1000 inactive=60sec;
Solution
Step 1: Recall correct open_file_cache syntax
The syntax requires named parameters like max= and inactive= with time units.
Step 2: Check each option for correctness
open_file_cache max=1000 inactive=60s; uses correct parameter names and time unit s for seconds.
Final Answer:
open_file_cache max=1000 inactive=60s; -> Option C
Quick Check:
Use named params with units for open_file_cache [OK]
Hint: Use named parameters with units like 'inactive=60s' [OK]