0
0
Nginxdevops~20 mins

FastCGI cache in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
FastCGI Cache Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
FastCGI cache status header output
You have enabled FastCGI cache in nginx with the directive fastcgi_cache_use_stale error timeout updating. When a cached response is served, nginx adds a header X-Cache-Status. What is the value of this header when nginx serves a stale cached response due to an upstream timeout?
A"HIT"
B"MISS"
C"STALE"
D"BYPASS"
Attempts:
2 left
💡 Hint
Think about what happens when nginx serves a cached response that is not fresh but still usable due to an upstream error.
Configuration
intermediate
1:30remaining
Correct FastCGI cache key configuration
Which of the following fastcgi_cache_key directives correctly creates a cache key that includes the host, request URI, and query string to uniquely cache requests?
Afastcgi_cache_key "$host$uri$is_args$args";
Bfastcgi_cache_key "$host$uri$query_string";
Cfastcgi_cache_key "$host$uri$args";
Dfastcgi_cache_key "$host$request_uri$query_string";
Attempts:
2 left
💡 Hint
Remember that $is_args adds a '?' only if there are query arguments.
Troubleshoot
advanced
2:00remaining
Diagnosing why FastCGI cache is not storing responses
You configured FastCGI cache in nginx, but no cached files appear in the cache directory after requests. Which of the following is the most likely cause?
AThe <code>fastcgi_cache_lock</code> directive is enabled.
BThe <code>fastcgi_cache_valid</code> directive is set to 0 seconds.
CThe <code>fastcgi_cache_use_stale</code> directive is not set.
DThe <code>fastcgi_cache_path</code> directive is missing or incorrectly set.
Attempts:
2 left
💡 Hint
Check if the cache directory and zone are properly defined.
🔀 Workflow
advanced
2:00remaining
Order of directives to enable FastCGI cache
Arrange the following nginx configuration steps in the correct order to enable FastCGI caching for PHP requests.
A1,2,4,3
B1,3,2,4
C2,1,3,4
D1,2,3,4
Attempts:
2 left
💡 Hint
Think about defining the cache storage first, then key, then validity, and finally enabling cache usage.
Best Practice
expert
2:30remaining
Best practice for cache purging with FastCGI cache
Which method is considered best practice to safely purge specific cached content in nginx FastCGI cache without restarting nginx or deleting cache files manually?
ASet <code>fastcgi_cache_valid</code> to a very low value to expire cache quickly.
BUse <code>fastcgi_cache_purge</code> directive with a location block and send HTTP PURGE requests.
CManually delete cache files from the cache directory and reload nginx.
DRestart nginx to clear all cached content.
Attempts:
2 left
💡 Hint
Look for a method that allows selective cache removal via HTTP requests.