Challenge - 5 Problems
Cache Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
Cache validity with expires directive
What is the HTTP response header
Expires value when the following nginx configuration is applied?location /images/ {
expires 10d;
}Attempts:
2 left
💡 Hint
The
expires directive sets the cache duration relative to the response time.✗ Incorrect
The
expires 10d; directive tells nginx to add an Expires header 10 days in the future from the response time, making the cache valid for 10 days.🧠 Conceptual
intermediate1:30remaining
Understanding cache-control max-age
Which statement correctly describes the effect of
add_header Cache-Control "max-age=3600"; in nginx configuration?Attempts:
2 left
💡 Hint
max-age is measured in seconds.
✗ Incorrect
The
Cache-Control: max-age=3600 header tells browsers and proxies to consider the cached response fresh for 3600 seconds (1 hour) after it is received.❓ Troubleshoot
advanced2:00remaining
Diagnosing cache not expiring as expected
You configured nginx with
expires 5m; but clients still receive cached content after 10 minutes. What is the most likely cause?Attempts:
2 left
💡 Hint
Check headers sent by the backend server.
✗ Incorrect
If the backend server sends Cache-Control headers with longer max-age or no-cache, they can override nginx's
expires directive, causing clients to cache longer than expected.🔀 Workflow
advanced2:00remaining
Configuring cache validity for API responses
You want to cache API responses for 30 seconds but ensure clients always revalidate after that. Which nginx configuration snippet achieves this?
Attempts:
2 left
💡 Hint
Use Cache-Control directives to control revalidation.
✗ Incorrect
The
max-age=30, must-revalidate tells clients to cache for 30 seconds but revalidate with the server after that period before using the cached response.✅ Best Practice
expert2:30remaining
Best practice for cache validity with varying content
You serve images that rarely change and JSON data that updates frequently. What is the best cache validity strategy in nginx to optimize performance and freshness?
Attempts:
2 left
💡 Hint
Different content types need different cache durations.
✗ Incorrect
Images that rarely change benefit from long cache validity to reduce load, while JSON data should have short cache times with revalidation to ensure freshness.