0
0
Nginxdevops~20 mins

Cache-Control headers in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Cache-Control Mastery
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 Cache-Control header in nginx?
Given this nginx configuration snippet, what Cache-Control header will be sent to clients?
location /images/ {
  add_header Cache-Control "public, max-age=86400";
}
Nginx
curl -I http://example.com/images/logo.png
ACache-Control: public, max-age=86400
BCache-Control: no-cache
CCache-Control: private, max-age=86400
DCache-Control: no-store
Attempts:
2 left
💡 Hint
Look at the add_header directive and the value it sets.
🧠 Conceptual
intermediate
2:00remaining
Which Cache-Control directive prevents caching by browsers but allows caching by proxies?
Select the Cache-Control directive that stops browsers from caching but still allows intermediate proxies to cache the response.
Ano-store
Bprivate
Cpublic
Dno-cache
Attempts:
2 left
💡 Hint
Think about which directive requires revalidation but does not forbid caching.
Configuration
advanced
2:00remaining
How to configure nginx to disable caching for all HTML files?
Choose the correct nginx configuration snippet that disables caching for all .html files by setting Cache-Control headers.
A
location ~* \.html$ {
  add_header Cache-Control "public, max-age=3600";
}
B
location ~* \.html$ {
  add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
}
C
location ~* \.html$ {
  add_header Cache-Control "private, max-age=86400";
}
D
location ~* \.html$ {
  add_header Cache-Control "max-age=31536000";
}
Attempts:
2 left
💡 Hint
Disabling caching means telling browsers and proxies not to store the response.
Troubleshoot
advanced
2:00remaining
Why is nginx not sending Cache-Control headers despite add_header directive?
You added 'add_header Cache-Control "max-age=3600";' inside a location block, but curl responses do not show Cache-Control headers. What is the most likely reason?
ACache-Control headers are overridden by browser settings
BThe syntax of add_header is incorrect and causes it to be ignored
CThe add_header directive is ignored for 4xx and 5xx responses by default
Dnginx does not support Cache-Control headers
Attempts:
2 left
💡 Hint
Check nginx behavior for error responses and add_header.
🔀 Workflow
expert
2:00remaining
Order the steps to implement and verify Cache-Control headers in nginx
Put these steps in the correct order to add Cache-Control headers and verify they work.
A1,2,3,4
B2,1,3,4
C1,3,2,4
D3,1,2,4
Attempts:
2 left
💡 Hint
Think about editing config, applying it, then testing.