Recall & Review
beginner
What is a proxy cache key in nginx?
A proxy cache key is a unique identifier nginx uses to store and retrieve cached content for a request. It helps nginx know which cached response to serve for a given request.
Click to reveal answer
intermediate
How do you define a custom proxy cache key in nginx?
You define a custom proxy cache key using the
proxy_cache_key directive inside a location or server block. It can include variables like $scheme, $host, and $request_uri.Click to reveal answer
intermediate
Why would you customize the proxy cache key instead of using the default?
Customizing the cache key lets you control cache granularity. For example, you can ignore query strings or include headers to cache different versions of a page separately.
Click to reveal answer
intermediate
Example of a proxy_cache_key directive that ignores query strings?
proxy_cache_key "$scheme://$host$uri";
This key uses the scheme, host, and URI but ignores query strings, so requests with different queries share the same cache.
Click to reveal answer
beginner
What happens if two different requests have the same proxy cache key?
Nginx will serve the same cached response for both requests, which can improve speed but may cause incorrect content if the requests should be different.
Click to reveal answer
What does the proxy_cache_key directive control in nginx?
✗ Incorrect
The proxy_cache_key directive sets the unique key nginx uses to find cached content for each request.
Which variable is NOT commonly used in proxy_cache_key?
✗ Incorrect
$remote_addr is the client IP and is not typically used in cache keys because it would create many unique keys.
What is the effect of ignoring query strings in the proxy_cache_key?
✗ Incorrect
Ignoring query strings means requests with different queries use the same cache key and share cached content.
Where do you place the proxy_cache_key directive?
✗ Incorrect
proxy_cache_key is set inside location or server blocks to control caching per request path.
What happens if two different URLs have the same proxy cache key?
✗ Incorrect
Same cache key means nginx serves the same cached content for both URLs.
Explain what a proxy cache key is and why it is important in nginx caching.
Think about how nginx knows which cached content to serve for a request.
You got /3 concepts.
Describe how you would customize the proxy_cache_key to ignore query strings and why you might want to do that.
Consider how different URLs with query parameters might share cache.
You got /3 concepts.