0
0
Nginxdevops~10 mins

FastCGI cache 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 enable FastCGI cache in nginx configuration.

Nginx
fastcgi_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=1g
Bmax_size=100m
Cmax_size=10g
Dmax_size=500m
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the max_size directive causes unlimited cache size.
Using too large cache size without enough disk space.
2fill in blank
medium

Complete the code to set the cache key for FastCGI cache.

Nginx
fastcgi_cache_key [1];
Drag options to blanks, or click blank then click option'
A$scheme$host$request_uri
B$scheme$request_method$host$request_uri$request_body
C$scheme$request_method$host$request_uri
D$host$request_uri
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving out request method can cause cache collisions.
Including request body in cache key is not typical.
3fill in blank
hard

Fix the error in the FastCGI cache configuration to enable caching in the location block.

Nginx
location ~ \.php$ {
    fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    fastcgi_cache [1];
    include fastcgi_params;
}
Drag options to blanks, or click blank then click option'
Amy_cache
Bcache_zone
Cfast_cache
Dcache
Attempts:
3 left
💡 Hint
Common Mistakes
Using an undefined cache zone name causes nginx to fail.
Misspelling the cache zone name.
4fill in blank
hard

Fill both blanks to set cache validity times for different response codes.

Nginx
fastcgi_cache_valid 200 [1];
fastcgi_cache_valid 404 [2];
Drag options to blanks, or click blank then click option'
A10m
B1m
C5m
D30s
Attempts:
3 left
💡 Hint
Common Mistakes
Caching 404 errors for too long can cause stale error pages.
Using invalid time units causes nginx errors.
5fill in blank
hard

Fill all three blanks to configure cache bypass and cache use conditions.

Nginx
fastcgi_cache_bypass [1];
fastcgi_no_cache [2];
fastcgi_cache_use_stale [3];
Drag options to blanks, or click blank then click option'
A$http_cache_control
B$cookie_nocache
Cerror timeout invalid_header http_500
D$request_method
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up variables for bypass and no_cache.
Not specifying error types for stale cache use.