0
0
Nginxdevops~5 mins

Expires directive in Nginx - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the expires directive in nginx?
The expires directive sets the caching time for responses, telling browsers how long to keep files before requesting them again.
Click to reveal answer
beginner
How do you set a file to expire 1 hour after it is served using the expires directive?
Use expires 1h; inside the location or server block to tell browsers to cache the file for 1 hour.
Click to reveal answer
intermediate
What does expires max; do in nginx?
It sets the cache expiration to a very long time (about 10 years), effectively telling browsers to keep the file indefinitely.
Click to reveal answer
intermediate
How does the expires directive affect HTTP headers?
It modifies the Expires and Cache-Control headers to control browser caching behavior.
Click to reveal answer
advanced
Can the expires directive use negative values? What happens if you use expires -1;?
Yes, negative values are allowed. expires -1; tells browsers not to cache the response and to revalidate it every time.
Click to reveal answer
What does expires 30d; mean in an nginx config?
AExpire the file immediately
BCache the file for 30 days
CCache the file for 30 minutes
DDisable caching
Which HTTP headers does the expires directive modify?
AUser-Agent and Referer
BContent-Type and Content-Length
CAuthorization and Cookie
DExpires and Cache-Control
What happens if you set expires off; in nginx?
ACaches files forever
BSets cache to 1 hour
CDisables setting the Expires header
DCauses an error
How would you tell nginx to set caching to 10 minutes?
Aexpires 10m;
Bexpires 10h;
Cexpires 10s;
Dexpires 10d;
What is the effect of expires -1; in nginx?
APrevents caching and forces revalidation
BCaches for 1 second
CCaches forever
DCaches for 1 minute
Explain how the expires directive controls browser caching in nginx.
Think about how browsers know when to ask for a new file.
You got /5 concepts.
    Describe a scenario where you would use expires max; and why.
    Consider files that don’t change often and can be cached for a long time.
    You got /4 concepts.