0
0
Nginxdevops~20 mins

Proxy cache key in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Proxy Cache Key Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the effective cache key with this configuration?
Given this nginx proxy cache key configuration, what is the resulting cache key for a request with host 'example.com' and URI '/index.html'?
Nginx
proxy_cache_key "$host$request_uri";
A"example.com/index.html"
B"/index.html"
C"example.com"
D"$host$request_uri"
Attempts:
2 left
💡 Hint
The variables $host and $request_uri are replaced by their values in the cache key string.
🧠 Conceptual
intermediate
1:30remaining
Why customize proxy_cache_key in nginx?
What is the main reason to customize the proxy_cache_key in nginx proxy caching?
ATo disable caching completely
BTo control how requests are grouped and cached based on request properties
CTo set the cache expiration time
DTo change the backend server IP address
Attempts:
2 left
💡 Hint
Think about what the cache key represents in caching.
Configuration
advanced
2:00remaining
Select the correct proxy_cache_key to cache by host and URI only
Which proxy_cache_key configuration caches responses uniquely by host and URI, ignoring query parameters?
Aproxy_cache_key "$host$uri";
Bproxy_cache_key "$host$request_uri";
Cproxy_cache_key "$host$args";
Dproxy_cache_key "$uri$args";
Attempts:
2 left
💡 Hint
$uri excludes query parameters, $request_uri includes them.
Troubleshoot
advanced
2:30remaining
Why does nginx cache miss occur despite identical URLs?
You configured proxy_cache_key as "$host$request_uri" but see cache misses for requests with same URL but different 'User-Agent' headers. What is the likely cause?
AThe proxy_cache_key syntax is invalid causing cache misses
Bnginx ignores proxy_cache_key and caches by IP address
CThe backend server varies response by 'User-Agent', causing different content despite same cache key
DThe cache key does not include 'User-Agent', so cache misses are unexpected
Attempts:
2 left
💡 Hint
Consider how backend response variations affect caching.
Best Practice
expert
3:00remaining
Best practice for proxy_cache_key with dynamic query parameters
You want to cache responses but ignore certain query parameters like 'session' and 'tracking' in the cache key. Which approach is best?
ADisable caching for requests with query parameters
BSet proxy_cache_key to "$host$request_uri" to include all query parameters
CUse proxy_cache_key "$host$uri$args" without filtering
DUse a map to filter unwanted query parameters and build proxy_cache_key with filtered args
Attempts:
2 left
💡 Hint
Think about how to exclude specific query parameters from cache key.