0
0
Nginxdevops~20 mins

Proxy cache basics in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Proxy Cache Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this Nginx cache status header?
You have configured Nginx with proxy_cache and added the header X-Cache-Status to responses. After a client requests a cached resource twice, what will be the value of X-Cache-Status in the second response?
Nginx
proxy_cache_path /tmp/cache levels=1:2 keys_zone=mycache:10m max_size=1g inactive=60m;
server {
    location / {
        proxy_cache mycache;
        proxy_pass http://backend;
        add_header X-Cache-Status $upstream_cache_status;
    }
}
A"EXPIRED"
B"MISS"
C"HIT"
D"BYPASS"
Attempts:
2 left
💡 Hint
Think about what happens when a cached response is served again.
Configuration
intermediate
2:00remaining
Which configuration snippet correctly sets up proxy cache with a 30-minute inactive timeout?
You want to configure Nginx proxy cache to store cached files and remove them if they are not accessed for 30 minutes. Which snippet correctly sets this?
Aproxy_cache_path /var/cache/nginx levels=1:2 keys_zone=cache_zone:10m max_size=500m inactive=30m;
Bproxy_cache_path /var/cache/nginx levels=1:2 keys_zone=cache_zone:10m max_size=500m inactive=30s;
Cproxy_cache_path /var/cache/nginx levels=1:2 keys_zone=cache_zone:10m max_size=500m inactive=30h;
Dproxy_cache_path /var/cache/nginx levels=1:2 keys_zone=cache_zone:10m max_size=500m inactive=300m;
Attempts:
2 left
💡 Hint
The inactive parameter uses time units like s, m, h for seconds, minutes, hours.
Troubleshoot
advanced
2:00remaining
Why does Nginx not cache responses despite proxy_cache configured?
You configured proxy_cache in Nginx, but responses are never cached. Which reason below explains this behavior?
AThe proxy_cache_valid directive is set to 0.
BThe backend server sends Cache-Control: no-store header.
CThe proxy_pass URL is incorrect.
DThe proxy_cache_path directive is missing.
Attempts:
2 left
💡 Hint
Check what response headers from backend can prevent caching.
🔀 Workflow
advanced
2:00remaining
What is the correct order of steps to enable proxy caching in Nginx?
Arrange these steps in the correct order to enable proxy caching in Nginx.
A1,2,3,4
B2,1,3,4
C1,3,2,4
D3,1,2,4
Attempts:
2 left
💡 Hint
Think about defining cache first, then enabling it, then proxying, then headers.
Best Practice
expert
2:00remaining
Which option is the best practice to avoid caching sensitive user data in Nginx proxy cache?
You want to ensure Nginx proxy cache does not store responses containing sensitive user data. Which configuration is best?
AUse proxy_cache_lock to prevent multiple cache writes.
BSet proxy_cache_valid 0 for all responses.
CDisable proxy_cache entirely.
DUse proxy_cache_bypass with a condition checking for cookies indicating logged-in users.
Attempts:
2 left
💡 Hint
Think about bypassing cache selectively based on user state.