0
0
Nginxdevops~20 mins

Purging cached content in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Cache Purge Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
What is the output of this command to purge cache in Nginx?
You run the following command to purge a cached file in Nginx cache directory:
rm -rf /var/cache/nginx/*

What is the expected result?
Nginx
rm -rf /var/cache/nginx/*
AThe command deletes only files named '*' literally.
BOnly cached files older than 7 days are deleted.
CThe command returns an error because of missing sudo privileges.
DAll cached files in /var/cache/nginx/ are deleted immediately.
Attempts:
2 left
💡 Hint
Think about what the wildcard * means in shell commands.
Configuration
intermediate
2:00remaining
Which Nginx configuration snippet enables cache purging via HTTP request?
You want to allow cache purging by sending a special HTTP request to Nginx. Which configuration snippet correctly enables this?
Nginx
location ~ ^/purge(/.*) {
    allow 127.0.0.1;
    deny all;
    proxy_cache_purge my_cache $1;
}
A
location ~ ^/purge(/.*) {
    allow 127.0.0.1;
    deny all;
    proxy_cache_purge my_cache $1;
}
B
location /purge/ {
    proxy_cache_purge my_cache $request_uri;
    allow all;
}
C
location /purge/ {
    deny 127.0.0.1;
    allow all;
    proxy_cache_purge my_cache $request_uri;
}
D
location /purge/ {
    proxy_cache_bypass my_cache $request_uri;
    allow 127.0.0.1;
    deny all;
}
Attempts:
2 left
💡 Hint
Remember to restrict purge access to localhost only.
Troubleshoot
advanced
2:00remaining
Why does the cache not purge after sending a PURGE request?
You configured Nginx to allow PURGE requests to clear cache, but after sending a PURGE request, the cache remains. What is the most likely cause?
AThe PURGE request was sent from an unauthorized IP address.
BThe cache directory is empty, so nothing to purge.
CThe PURGE method is not allowed in the Nginx configuration.
DThe proxy_cache_path directive is missing.
Attempts:
2 left
💡 Hint
Check IP restrictions in your purge location block.
🔀 Workflow
advanced
2:30remaining
What is the correct workflow to safely purge a specific cached URL in Nginx?
You want to purge the cached content for URL /images/logo.png without affecting other cached files. What is the correct sequence of steps?
A2,4,1,3
B2,1,3,4
C1,2,3,4
D4,2,1,3
Attempts:
2 left
💡 Hint
Think about verifying config before purging and checking logs after.
Best Practice
expert
3:00remaining
Which practice is best for purging cached content in a high-traffic Nginx environment?
In a busy production environment, what is the best practice to purge cached content without causing downtime or performance issues?
ADisable caching temporarily during purging to avoid stale content.
BManually delete all cache files daily with rm -rf to ensure freshness.
CUse HTTP PURGE requests restricted by IP and automate purging only for changed URLs.
DReload Nginx after every PURGE request to apply changes immediately.
Attempts:
2 left
💡 Hint
Think about minimizing impact and targeting only needed cache entries.