Upload
michal-czeraszkiewicz
View
127
Download
0
Embed Size (px)
Citation preview
Configuration - Available Directives
proxy_cache_path /data/nginx/cache keys_zone=zone_name_one:10m;
proxy_cache zone_name_one;
Configuration - Available Directives
proxy_cache_path /data/nginx/cache keys_zone=one:10m max_size=200m;
proxy_cache_path /data/nginx/cache keys_zone=one:10m inactive=60m;
Configuration - Available Directives
proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=one:10m;
What/When to cache?
proxy_cache_methods GET HEAD POST;
proxy_cache_min_uses 5;
proxy_cache_revalidate on;
How to cache?
proxy_cache_key "$host$request_uri$cookie_user";
proxy_cache_key "$scheme$proxy_host$uri$is_args$args";
Other Configuration Options
proxy_cache_use_stale error timeout;
proxy_cache_lock on;
proxy_temp_path /tmp/custom_cache/;
Debugging Nginx's Cache
map $remote_addr $cache_status { 127.0.0.1 $upstream_cache_status; default "";}...add_header X-Cache-Status $cache_status;
MISS Object was not found in the cache. Response was served from the origin.
Response may have been saved to cache.
BYPASS Got response from upstream. Response may have been saved to cache.
EXPIRED Cached object has expired. Response was served from the upstream.
STALE Object served from cache because of issues with origin server response
UPDATING Serve stale content from cache because proxy_cache_lock has timed out
and proxy_use_stale takes control
REVALIDATED proxy_cache_revalidate verified that the current cached content was still
valid
HIT The object was found in the cache and it is served from there
Cache Loader
proxy_cache_path /data/nginx/cache keys_zone=one:10m [loader_files=number] [loader_sleep=time] [loader_threshold=time];