0
0
Nginxdevops~10 mins

Why caching improves response times in Nginx - Test Your Understanding

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

Complete the code to enable basic caching in nginx.

Nginx
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=my_cache:10m [1] inactive=60m;
Drag options to blanks, or click blank then click option'
Amax_size=10g
Bmax_size=1g
Cmax_size=100m
Dmax_size=500m
Attempts:
3 left
💡 Hint
Common Mistakes
Using too small cache size limits caching benefits.
Omitting the max_size directive.
2fill in blank
medium

Complete the code to enable caching for a proxy location in nginx.

Nginx
location /api/ {
    proxy_cache my_cache;
    proxy_pass http://backend_server;
    proxy_cache_valid 200 [1];
}
Drag options to blanks, or click blank then click option'
A1h
B10m
C30s
D5h
Attempts:
3 left
💡 Hint
Common Mistakes
Setting cache time too short, reducing caching benefits.
Using invalid time format.
3fill in blank
hard

Fix the error in the caching configuration to properly enable caching.

Nginx
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=my_cache:10m max_size=1g inactive=60m;

location /static/ {
    proxy_pass http://backend;
    proxy_cache [1];
}
Drag options to blanks, or click blank then click option'
Acache_zone
Bmycache
Ccache_my
Dmy_cache
Attempts:
3 left
💡 Hint
Common Mistakes
Misspelling the cache zone name.
Using a different name than defined.
4fill in blank
hard

Fill both blanks to configure nginx to cache only GET requests and bypass caching for POST requests.

Nginx
proxy_cache_methods [1];
proxy_cache_bypass [2];
Drag options to blanks, or click blank then click option'
AGET
BPOST
CPUT
DDELETE
Attempts:
3 left
💡 Hint
Common Mistakes
Caching POST requests causing stale data.
Not specifying methods correctly.
5fill in blank
hard

Fill both blanks to create a cache key that includes the host, URI, and query string.

Nginx
proxy_cache_key [1]$host:$request_uri[2]$query_string;
Drag options to blanks, or click blank then click option'
A"
B_
C:
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Missing quotes causing syntax errors.
Using wrong separators causing cache misses.