From 090aff0338ec4f5a987abef62f20a68e233ea28f Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Tue, 28 Feb 2017 15:59:01 -0500 Subject: [PATCH] Cache for a longer time on Fastly --- website/scripts/deploy.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/website/scripts/deploy.sh b/website/scripts/deploy.sh index 1d8141a6a4..cf99fba9c7 100755 --- a/website/scripts/deploy.sh +++ b/website/scripts/deploy.sh @@ -48,6 +48,9 @@ if [ -z "$NO_UPLOAD" ]; then exit 1 fi + # Set browser-side cache-control to ~4h, but tell Fastly to cache for much + # longer. We manually purge the Fastly cache, so setting it to a year is more + # than fine. s3cmd \ --quiet \ --delete-removed \ @@ -56,6 +59,7 @@ if [ -z "$NO_UPLOAD" ]; then --acl-public \ --recursive \ --add-header="Cache-Control: max-age=14400" \ + --add-header="x-amz-meta-surrogate-control: max-age=31536000" \ --add-header="x-amz-meta-surrogate-key: site-$PROJECT" \ sync "$DIR/build/" "s3://hc-sites/$PROJECT/latest/" @@ -89,7 +93,7 @@ if [ -z "$NO_UPLOAD" ]; then modify "s3://hc-sites/$PROJECT/latest/" fi -# Perform a soft-purge of the surrogate key. +# Perform a purge of the surrogate key. if [ -z "$NO_PURGE" ]; then echo "Purging Fastly cache..." curl \ @@ -99,7 +103,6 @@ if [ -z "$NO_PURGE" ]; then --request "POST" \ --header "Accept: application/json" \ --header "Fastly-Key: $FASTLY_API_KEY" \ - --header "Fastly-Soft-Purge: 1" \ "https://api.fastly.com/service/$FASTLY_SERVICE_ID/purge/site-$PROJECT" fi