Challenge - 5 Problems
Proxy Cache Key Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2: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";Attempts:
2 left
💡 Hint
The variables $host and $request_uri are replaced by their values in the cache key string.
✗ Incorrect
The proxy_cache_key directive uses variables. Here, $host is 'example.com' and $request_uri is '/index.html', so the key becomes 'example.com/index.html'.
🧠 Conceptual
intermediate1:30remaining
Why customize proxy_cache_key in nginx?
What is the main reason to customize the proxy_cache_key in nginx proxy caching?
Attempts:
2 left
💡 Hint
Think about what the cache key represents in caching.
✗ Incorrect
The proxy_cache_key defines how nginx identifies unique cache entries. Customizing it lets you control which requests share cached content.
❓ Configuration
advanced2: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?
Attempts:
2 left
💡 Hint
$uri excludes query parameters, $request_uri includes them.
✗ Incorrect
The $uri variable contains the normalized URI without query parameters, so caching by "$host$uri" ignores query strings.
❓ Troubleshoot
advanced2: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?
Attempts:
2 left
💡 Hint
Consider how backend response variations affect caching.
✗ Incorrect
If backend responses differ by 'User-Agent' but cache key ignores it, nginx caches one version but serves wrong content, so it may bypass cache causing misses.
✅ Best Practice
expert3: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?
Attempts:
2 left
💡 Hint
Think about how to exclude specific query parameters from cache key.
✗ Incorrect
Using a map to filter query parameters lets you exclude unwanted ones from cache key, improving cache hit ratio and avoiding cache fragmentation.