diff --git a/common.conf b/common.conf index bf1b0e6..cc8c224 100644 --- a/common.conf +++ b/common.conf @@ -137,6 +137,7 @@ location /map/v1/ { proxy_pass http://hsl-map-server:8080; proxy_cache tiles; proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504; + proxy_cache_key $map_cache_key; proxy_cache_revalidate on; proxy_cache_lock on; proxy_redirect off; @@ -150,6 +151,7 @@ location /map/v2/ { proxy_pass http://hsl-map-server:8080; proxy_cache tiles; proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504; + proxy_cache_key $map_cache_key; proxy_cache_revalidate on; proxy_cache_lock on; proxy_redirect off; @@ -164,6 +166,7 @@ location /map/v3/ { proxy_pass http://hsl-map-server:8080; proxy_cache tiles; proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504; + proxy_cache_key $map_cache_key; proxy_cache_revalidate on; proxy_cache_lock on; proxy_redirect off; diff --git a/nginx.conf b/nginx.conf index a271313..2d4d9b6 100644 --- a/nginx.conf +++ b/nginx.conf @@ -8,12 +8,17 @@ daemon off; # because nginx doesn't copy port to redirects but always adds :8080 http { - + # map custom proxy cache keys for geocoding and maps map $request_uri $geo_cache_key { "~(?geocoding\/v1\/(.*)\?)digitransit-subscription-key=((.*?)\&)(?(.*))" $location$params; default $request_uri; } + map $request_uri $map_cache_key { + "~(?(.*map\/.*))\?digitransit-subscription-key=((.*))" $key_part; + default $request_uri; + } + log_format custom '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_user_agent" $host $request_time';