0
0
Nginxdevops~10 mins

Cache bypass conditions 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 bypass cache when the request method is POST.

Nginx
if ($request_method = [1]) {
    set $bypass_cache 1;
}
Drag options to blanks, or click blank then click option'
APOST
BGET
CHEAD
DPUT
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET instead of POST, which is safe to cache.
Using PUT which is less common for cache bypass.
2fill in blank
medium

Complete the code to bypass cache when the request has a cookie named 'session'.

Nginx
if ($http_cookie ~* [1]) {
    set $bypass_cache 1;
}
Drag options to blanks, or click blank then click option'
A"user_id"
B"session"
C"auth"
D"token"
Attempts:
3 left
💡 Hint
Common Mistakes
Using cookie names unrelated to sessions like 'user_id'.
Forgetting to quote the cookie name in regex.
3fill in blank
hard

Fix the error in the code to bypass cache when the query string contains 'nocache=1'.

Nginx
if ($arg_nocache [1] 1) {
    set $bypass_cache 1;
}
Drag options to blanks, or click blank then click option'
A=
B!=
C==
D~
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' which assigns instead of compares.
Using '~' which is for regex matching.
4fill in blank
hard

Fill both blanks to bypass cache when the request method is POST or the cookie 'session' exists.

Nginx
if ($request_method = [1] || $http_cookie ~* [2]) {
    set $bypass_cache 1;
}
Drag options to blanks, or click blank then click option'
APOST
BGET
C"session"
D"user"
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET instead of POST for method.
Using wrong cookie name like 'user'.
5fill in blank
hard

Fill all three blanks to bypass cache when the request method is POST, or the cookie 'session' exists, or the query string 'nocache=1' is present.

Nginx
if ($request_method = [1] || $http_cookie ~* [2] || $arg_nocache [3] 1) {
    set $bypass_cache 1;
}
Drag options to blanks, or click blank then click option'
APOST
B"session"
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' instead of '==' for query string comparison.
Wrong cookie name or method.