caching - nginx - create multiple cache paths -
i new nginx, i'm not sure if possible.
however, attempting create short, long, , never caches sites use.
i naively attempted set these in http block:
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=short:10m; proxy_cache short; proxy_cache_key "short:$scheme$proxy_host$uri$is_args$args"; proxy_cache_valid 2m; proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=long:10m; proxy_cache long; proxy_cache_key "long:$scheme$proxy_host$uri$is_args$args"; proxy_cache_valid 1h; proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=day:10m; proxy_cache never; proxy_cache_key "long:$scheme$proxy_host$uri$is_args$args"; proxy_cache_valid 1d; proxy_cache off;
upon reload throws next error:
[emerg]: "proxy_cache" directive duplicate in
how can setup different cache paths share among virtual hosts?
the proxy_cache
directive means "use cache right in block" using directive multiple times nginx can't decide cache utilize , shows , error. must remove proxy_cache
, proxy_cache_valid
directives , utilize 1 of each @ time in location and/or server blocks.
you must know usage of proxy_cache
, proxy_cache_valid
directives forbidden in if
blocks may not want way (i'm assuming select particular cache based on test).
therefore, other approach utilize specific headers in upstream's reply. can utilize 1 of next headers set caching time :
x-accel-expires
cache-control
expires
nginx honor these headers default. can tell him ignore of when deciding caching duration proxy_ignore_headers
.
caching nginx
No comments:
Post a Comment