0
0
Nginxdevops~20 mins

Micro-caching for dynamic content in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Micro-caching Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the effect of this micro-caching configuration snippet?
Given the following nginx configuration snippet, what will be the output behavior when a user requests a dynamic page?
Nginx
location /dynamic/ {
    proxy_cache my_cache;
    proxy_cache_valid 200 1s;
    proxy_pass http://backend;
}
AAll responses are cached indefinitely, causing stale content to be served.
BNo caching occurs because proxy_cache_valid is set to 1 second, which is too short to cache.
CResponses with status 200 are cached for 1 second, reducing backend load for rapid repeated requests.
DOnly error responses are cached for 1 second, normal responses bypass cache.
Attempts:
2 left
💡 Hint
proxy_cache_valid controls how long responses with specific status codes are cached.
Configuration
intermediate
2:00remaining
Choose the correct nginx micro-caching configuration to cache only GET requests for 2 seconds
Which configuration snippet correctly enables micro-caching for only GET requests with a 2-second cache duration?
A
location / {
    proxy_cache my_cache;
    proxy_cache_methods GET;
    proxy_cache_valid 200 2s;
    proxy_pass http://backend;
}
B
location / {
    proxy_cache my_cache;
    proxy_cache_methods POST;
    proxy_cache_valid 200 2s;
    proxy_pass http://backend;
}
C
location / {
    proxy_cache my_cache;
    proxy_cache_valid 200 2s;
    proxy_pass http://backend;
}
D
location / {
    proxy_cache my_cache;
    proxy_cache_methods GET POST;
    proxy_cache_valid 200 2s;
    proxy_pass http://backend;
}
Attempts:
2 left
💡 Hint
proxy_cache_methods controls which HTTP methods are cached.
Troubleshoot
advanced
2:00remaining
Why does micro-caching not work despite correct configuration?
An nginx server has micro-caching configured with proxy_cache_valid 200 1s; but no caching occurs. Which is the most likely cause?
AThe backend server is sending Cache-Control: no-cache headers, preventing caching.
BThe proxy_cache_path directive is missing, so cache storage is undefined.
CThe proxy_pass URL is incorrect, causing caching to fail silently.
DThe proxy_cache_valid directive only works for status 404, not 200.
Attempts:
2 left
💡 Hint
Headers from backend can prevent caching even if nginx is configured.
🔀 Workflow
advanced
2:00remaining
Order the steps to enable micro-caching for dynamic content in nginx
Put these steps in the correct order to enable micro-caching for dynamic content in nginx.
A3,1,2,4
B2,1,3,4
C1,3,2,4
D1,2,3,4
Attempts:
2 left
💡 Hint
Cache zone must be defined before enabling cache in location.
Best Practice
expert
2:00remaining
Which micro-caching strategy best balances freshness and backend load?
For a high-traffic dynamic website, which micro-caching configuration is best to balance content freshness and reduce backend load?
ACache only 200 responses for 1 second and ignore Cache-Control headers from backend.
BCache GET requests for 5 seconds and respect backend Cache-Control headers.
CDisable caching and rely on backend to handle all requests for freshest content.
DCache all responses including errors for 10 minutes to reduce backend calls.
Attempts:
2 left
💡 Hint
Respecting backend headers helps avoid stale content while caching reduces load.