Add server-side caching of proxy requests
This commit is contained in:
parent
830c93f2a7
commit
1ca4e3c3ea
@ -7,6 +7,16 @@ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
more_clear_headers 'Server';
|
||||
more_clear_headers 'X-Powered-By';
|
||||
|
||||
proxy_cache_path /var/cache/openresty levels=1:2 keys_zone=cache_proxy:10m max_size=1g inactive=24h use_temp_path=off;
|
||||
|
||||
map $upstream_http_cache_control $cache_condition {
|
||||
~*max-age=0|~*s-maxage=0 1;
|
||||
~*private|~*no-store 1;
|
||||
~*max-age=(\d+)|~*s-maxage=(\d+) 0;
|
||||
~*immutable 0;
|
||||
default 1;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 0.0.0.0:80;
|
||||
listen [::]:80 default_server;
|
||||
@ -15,6 +25,15 @@ server {
|
||||
|
||||
location / {
|
||||
proxy_pass http://$router_host:8092;
|
||||
|
||||
proxy_cache cache_proxy;
|
||||
proxy_cache_revalidate on;
|
||||
proxy_no_cache $cache_condition;
|
||||
proxy_cache_valid 200 206 301 120m;
|
||||
proxy_cache_valid 302 303 20m;
|
||||
proxy_cache_valid 404 410 3m;
|
||||
|
||||
add_header X-Cache-Status $upstream_cache_status;
|
||||
}
|
||||
|
||||
include includes/letsencrypt.conf;
|
||||
|
Loading…
Reference in New Issue
Block a user