Complete the code to enable proxy caching in nginx.
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=my_cache:10m [1] inactive=60m;
The max_size directive sets the maximum size of the cache. Here, max_size=100m limits the cache to 100 megabytes.
Complete the code to set the proxy cache key to the request URI.
proxy_cache_key [1];The proxy_cache_key defines the cache key. Using $request_uri caches based on the full request URI.
Fix the error in the proxy cache configuration to enable caching for 10 minutes.
proxy_cache_valid 200 302 [1];
The proxy_cache_valid directive requires a time with units like 'm' for minutes. '10m' means 10 minutes.
Fill both blanks to set cache control headers and enable proxy caching in the location block.
location / {
proxy_cache [1];
add_header [2] 'HIT from cache';
}proxy_cache my_cache; enables caching using the defined cache zone. add_header X-Cache-Status 'HIT from cache'; adds a header to indicate cache hits.
Fill all three blanks to create a dictionary of cached responses with keys as request URIs and values as status codes greater than 200.
cached_responses = { [1]: [2] for [3] in responses if responses[[1]] > 200 }This dictionary comprehension uses uri as the key and responses[uri] as the value, filtering for status codes greater than 200.