Challenge - 5 Problems
Cache Bypass Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Cache Bypass with Specific Header
Given the following nginx configuration snippet, what will be the cache behavior when a request contains the header
X-Bypass-Cache: true?Nginx
proxy_cache_bypass $http_x_bypass_cache; proxy_cache my_cache; proxy_cache_valid 200 1h;
Attempts:
2 left
💡 Hint
Check how the variable
$http_x_bypass_cache controls cache bypass.✗ Incorrect
The directive
proxy_cache_bypass uses the variable $http_x_bypass_cache. If this variable is set (e.g., header present), nginx bypasses the cache and forwards the request to the backend.❓ Configuration
intermediate2:00remaining
Condition to Bypass Cache for POST Requests
Which nginx configuration snippet correctly bypasses cache for POST requests?
Attempts:
2 left
💡 Hint
The variable
$request_method contains the HTTP method. Non-empty values cause bypass.✗ Incorrect
Setting
proxy_cache_bypass $request_method; causes cache bypass for all requests with a method set. Since POST requests have method 'POST', cache is bypassed for POST.❓ Troubleshoot
advanced2:00remaining
Unexpected Cache Bypass Behavior
An nginx server is configured with:
Users report cache is always bypassed even without the cookie
proxy_cache_bypass $cookie_nocache;
Users report cache is always bypassed even without the cookie
nocache. What is the most likely cause?Attempts:
2 left
💡 Hint
Verify the full cache configuration, especially
proxy_cache_valid.✗ Incorrect
The
proxy_cache_bypass $cookie_nocache; directive is correct for conditional bypass (bypasses only if cookie present and non-empty). However, caching requires proxy_cache_valid to specify response validity times. Without it, no responses are cached, so all requests go to the backend.🔀 Workflow
advanced2:00remaining
Implementing Cache Bypass Based on Query Parameter
You want to bypass cache only when the URL contains the query parameter
refresh=true. Which workflow correctly implements this in nginx?Attempts:
2 left
💡 Hint
Maps are preferred for conditional cache bypass based on variable values.
✗ Incorrect
Using a map allows setting a variable to 1 only when
$arg_refresh equals 'true'. Then proxy_cache_bypass uses that variable to bypass cache only in that case.🧠 Conceptual
expert2:00remaining
Effect of Multiple Conditions in proxy_cache_bypass
Consider this nginx configuration:
What is the effect of listing multiple variables in
proxy_cache_bypass $http_cache_control $cookie_nocache;
What is the effect of listing multiple variables in
proxy_cache_bypass?Attempts:
2 left
💡 Hint
Check how nginx evaluates multiple variables in
proxy_cache_bypass.✗ Incorrect
When multiple variables are listed, nginx bypasses cache if any variable is non-empty. This acts like a logical OR condition.