From 099f04cbd40f8bcf7d70e2a49d96faba6c84a02c Mon Sep 17 00:00:00 2001 From: Robert Lemke Date: Thu, 5 May 2022 10:54:10 +0200 Subject: [PATCH 1/2] Set Cache-Control header for proxied GCS resources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "expires" statement does not seem to have an effect – the lifetime provided by Google always won. However, providing Cache-Control might work and solve as a hotfix for flownative/flow-google-cloudstorage#32 #7 --- root-files/opt/flownative/lib/nginx-legacy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/root-files/opt/flownative/lib/nginx-legacy.sh b/root-files/opt/flownative/lib/nginx-legacy.sh index 231459e..86a0f93 100644 --- a/root-files/opt/flownative/lib/nginx-legacy.sh +++ b/root-files/opt/flownative/lib/nginx-legacy.sh @@ -191,9 +191,9 @@ EOM # pass persistent resource requests to GCS location ~* "^${BEACH_PERSISTENT_RESOURCES_BASE_PATH}([a-f0-9]{40})/" { resolver 8.8.8.8; - expires ${NGINX_STATIC_FILES_LIFETIME}; proxy_set_header Authorization ""; add_header Via 'Beach Asset Proxy'; + add_header Cache-Control 'public, max-age=${NGINX_STATIC_FILES_LIFETIME}'; ${addHeaderStrictTransportSecurity} proxy_pass http://storage.googleapis.com/${BEACH_GOOGLE_CLOUD_STORAGE_PUBLIC_BUCKET}/\$1\$is_args\$args; } From aeb16a17d06c6ce7694d21e6aa59ece64d54be15 Mon Sep 17 00:00:00 2001 From: Robert Lemke Date: Thu, 5 May 2022 10:54:52 +0200 Subject: [PATCH 2/2] Increase default cache lifetime for static files Google does not consider a lifetime of 30 days as long enough, but 6 months should work fine. #7 --- root-files/opt/flownative/lib/nginx.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/root-files/opt/flownative/lib/nginx.sh b/root-files/opt/flownative/lib/nginx.sh index 7716b33..fe4772e 100755 --- a/root-files/opt/flownative/lib/nginx.sh +++ b/root-files/opt/flownative/lib/nginx.sh @@ -38,7 +38,7 @@ export NGINX_CACHE_BACKGROUND_UPDATE="${NGINX_CACHE_BACKGROUND_UPDATE:-off}" export NGINX_CUSTOM_ERROR_PAGE_CODES="${NGINX_CUSTOM_ERROR_PAGE_CODES:-500 501 502 503}" export NGINX_CUSTOM_ERROR_PAGE_TARGET="${NGINX_CUSTOM_ERROR_PAGE_TARGET:-}" -export NGINX_STATIC_FILES_LIFETIME=${NGINX_STATIC_FILES_LIFETIME:-30d} +export NGINX_STATIC_FILES_LIFETIME=${NGINX_STATIC_FILES_LIFETIME:-6M} export PATH="${PATH}:${NGINX_BASE_PATH}/bin" EOF