0
0
Nginxdevops~5 mins

Proxy cache key in Nginx - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AHow nginx identifies cached content for requests
BThe timeout for cached content
CThe size of the cache
DThe location of the cache files
Which variable is NOT commonly used in proxy_cache_key?
A$scheme
B$remote_addr
C$request_uri
D$host
What is the effect of ignoring query strings in the proxy_cache_key?
ACache is disabled
BEach query string gets a separate cache entry
CDifferent query strings share the same cached content
DCache is cleared on every request
Where do you place the proxy_cache_key directive?
AInside location or server block
BOnly in http block
CIn the events block
DIn the mail block
What happens if two different URLs have the same proxy cache key?
ANginx caches both separately
BNginx returns an error
CCache is disabled for those URLs
DThey share the same cached response
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.