0
0
Nginxdevops~10 mins

Expires directive in Nginx - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the Expires header to 1 day.

Nginx
expires [1];
Drag options to blanks, or click blank then click option'
Aoff
B10m
Cmax
D1d
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'off' disables the Expires header.
Using 'max' sets a very long expiration, not 1 day.
Using '10m' sets 10 minutes, not 1 day.
2fill in blank
medium

Complete the code to disable the Expires header.

Nginx
expires [1];
Drag options to blanks, or click blank then click option'
Aoff
B1h
C30s
Dmax
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'max' enables very long caching.
Using time values like '1h' or '30s' sets caching durations instead of disabling.
3fill in blank
hard

Fix the error in the code to set Expires header to 10 minutes.

Nginx
expires [1];
Drag options to blanks, or click blank then click option'
A10minutes
B10m
C10min
D600s
Attempts:
3 left
💡 Hint
Common Mistakes
Using '10min' or '10minutes' causes syntax errors.
Using seconds like '600s' is valid but less common; '10m' is preferred.
4fill in blank
hard

Fill both blanks to set Expires header to 2 hours and disable it for a specific location.

Nginx
location /images/ {
    expires [1];
}
location /nocache/ {
    expires [2];
}
Drag options to blanks, or click blank then click option'
A2h
Boff
C1d
Dmax
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'max' instead of 'off' disables caching incorrectly.
Using '1d' instead of '2h' changes the caching duration.
5fill in blank
hard

Fill all three blanks to set Expires header with a variable, a time, and disable caching conditionally.

Nginx
set $cache_time [1];
if ($request_uri ~* ".*\.css$") {
    expires [2];
} else {
    expires [3];
}
Drag options to blanks, or click blank then click option'
A1d
Boff
C$cache_time
D10m
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name without setting it first.
Using 'off' for all files disables caching everywhere.
Using a time string directly instead of the variable in the else block.