0
0
Nginxdevops~20 mins

Cache bypass conditions in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Cache Bypass Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2: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;
AThe cache will be bypassed and the request will be forwarded to the backend.
BThe cache will be used normally, ignoring the header.
CThe cache will be cleared for all entries.
DThe request will be blocked with a 403 Forbidden error.
Attempts:
2 left
💡 Hint
Check how the variable $http_x_bypass_cache controls cache bypass.
Configuration
intermediate
2:00remaining
Condition to Bypass Cache for POST Requests
Which nginx configuration snippet correctly bypasses cache for POST requests?
Aproxy_cache_bypass $request_method;
Bproxy_cache_bypass $request_method = 'POST';
Cproxy_cache_bypass $request_method = POST;
Dproxy_cache_bypass $request_method =POST;
Attempts:
2 left
💡 Hint
The variable $request_method contains the HTTP method. Non-empty values cause bypass.
Troubleshoot
advanced
2:00remaining
Unexpected Cache Bypass Behavior
An nginx server is configured with:
proxy_cache_bypass $cookie_nocache;

Users report cache is always bypassed even without the cookie nocache. What is the most likely cause?
AThe variable <code>$cookie_nocache</code> is empty string, which still triggers bypass.
BThe cookie name is case-sensitive and should be <code>noCache</code>.
CThe configuration requires <code>proxy_cache_valid</code> to enable caching.
DThe variable <code>$cookie_nocache</code> is undefined and treated as empty, so cache is not bypassed.
Attempts:
2 left
💡 Hint
Verify the full cache configuration, especially proxy_cache_valid.
🔀 Workflow
advanced
2: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?
ADirectly use <code>proxy_cache_bypass $arg_refresh;</code> without any map.
BUse a map to set a variable to 1 if <code>$arg_refresh</code> equals 'true', then use that variable in <code>proxy_cache_bypass</code>.
CUse <code>if ($arg_refresh = 'true') { proxy_cache_bypass 1; }</code> inside location block.
DSet <code>proxy_cache_bypass $query_string;</code> to bypass cache when any query exists.
Attempts:
2 left
💡 Hint
Maps are preferred for conditional cache bypass based on variable values.
🧠 Conceptual
expert
2:00remaining
Effect of Multiple Conditions in proxy_cache_bypass
Consider this nginx configuration:
proxy_cache_bypass $http_cache_control $cookie_nocache;

What is the effect of listing multiple variables in proxy_cache_bypass?
ACache is bypassed only if all variables are non-empty (logical AND).
BCache is bypassed only if the first variable is non-empty; others are ignored.
CCache is never bypassed because multiple variables cause a syntax error.
DCache is bypassed if any one of the variables is non-empty (logical OR).
Attempts:
2 left
💡 Hint
Check how nginx evaluates multiple variables in proxy_cache_bypass.