Commit 6fdf8336 authored by Seth Vargo's avatar Seth Vargo Committed by Jeff Mitchell
Browse files

Cache for a longer time on Fastly (#2417)

parent aae23b1e
Branches unavailable v1.10.2 v1.10.1 v1.10.0 v1.10.0-rc1 v1.9.6 v1.9.5 v1.9.4 v1.9.3 v1.9.2 v1.9.1 v1.9.0 v1.9.0-rc1 v1.8.11 v1.8.10 v1.8.9 v1.8.8 v1.8.7 v1.8.6 v1.8.5 v1.8.4 v1.8.3 v1.8.2 v1.8.1 v1.8.0 v1.8.0-rc2 v1.8.0-rc1 v1.7.10 v1.7.9 v1.7.8 v1.7.7 v1.7.6 v1.7.5 v1.7.4 v1.7.3 v1.7.2 v1.7.1 v1.7.0 v1.7.0-rc2 v1.7.0-rc1 v1.6.7 v1.6.6 v1.6.5 v1.6.4 v1.6.3 v1.6.2 v1.6.1 v1.6.0 v1.6.0-rc v1.5.9 v1.5.8 v1.5.7 v1.5.6 v1.5.5 v1.5.4 v1.5.3 v1.5.2 v1.5.1 v1.5.0 v1.5.0-rc v1.4.7 v1.4.6 v1.4.5 v1.4.4 v1.4.3 v1.4.2 v1.4.1 v1.4.0 v1.4.0-rc1 v1.4.0-beta1 v1.3.10 v1.3.9 v1.3.8 v1.3.7 v1.3.6 v1.3.5 v1.3.4 v1.3.3 v1.3.2 v1.3.1 v1.3.0 v1.3.0-beta1 v1.2.7 v1.2.6 v1.2.5 v1.2.4 v1.2.3 v1.2.2 v1.2.1 v1.2.0 v1.2.0-rc1 v1.2.0-beta2 v1.2.0-beta1 v1.1.5 v1.1.4 v1.1.3 v1.1.2 v1.1.1 v1.1.0 v1.1.0-beta2 v1.1.0-beta1 v1.0.3 v1.0.2 v1.0.1 v1.0.0 v1.0.0-rc1 v1.0.0-beta2 v1.0.0-beta1 v0.11.6 v0.11.5 v0.11.4 v0.11.3 v0.11.2 v0.11.1 v0.11.0 v0.11.0-beta1 v0.10.4 v0.10.3 v0.10.2 v0.10.1 v0.10.0 v0.10.0-rc1 v0.9.6 v0.9.5 v0.9.4 v0.9.3 v0.9.2 v0.9.1 v0.9.0 v0.8.3 v0.8.2 v0.8.1 v0.8.0 v0.8.0-rc1 v0.8.0-beta1 v0.7.3 v0.7.2 v0.7.1 v0.7.0 v0.7.0-beta1 sdk/v0.4.1 sdk/v0.4.0 sdk/v0.3.0 sdk/v0.2.1 sdk/v0.2.0 sdk/v0.1.13 sdk/v0.1.12 sdk/v0.1.11 sdk/v0.1.10 sdk/v0.1.9 sdk/v0.1.8 old-stable-website old-stable-website-20210728 main-creation last-go-modable api/v1.5.0 api/v1.4.1 api/v1.4.0 api/v1.3.1 api/v1.3.0 api/v1.2.0 api/v1.1.1 api/v1.1.0 api/v1.0.4 api/v1.0.3 api/v1.0.2 api/v1.0.1 api/auth/userpass/v0.1.0 api/auth/ldap/v0.1.0 api/auth/kubernetes/v0.1.0 api/auth/gcp/v0.1.0 api/auth/azure/v0.1.0 api/auth/aws/v0.1.0 api/auth/approle/v0.1.1 api/auth/approle/v0.1.0
No related merge requests found
Showing with 14 additions and 7 deletions
+14 -7
......@@ -28,11 +28,8 @@ if ! command -v "s3cmd" >/dev/null 2>&1; then
exit 1
fi
# Get the parent directory of where this script is and change into our website
# directory
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
DIR="$(cd -P "$( dirname "$SOURCE" )/.." && pwd)"
# Get the parent directory of where this script is and cd there
DIR="$(cd "$(dirname "$(readlink -f "$0")")/.." && pwd)"
# Delete any .DS_Store files for our OS X friends.
find "$DIR" -type f -name '.DS_Store' -delete
......@@ -51,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 \
......@@ -59,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/"
......@@ -92,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 \
......@@ -102,13 +103,19 @@ 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
# Warm the cache with recursive wget.
if [ -z "$NO_WARM" ]; then
echo "Warming Fastly cache..."
echo ""
echo "If this step fails, there are likely missing or broken assets or links"
echo "on the website. Run the following command manually on your laptop, and"
echo "search for \"ERROR\" in the output:"
echo ""
echo "wget --recursive --delete-after https://$PROJECT_URL/"
echo ""
wget \
--recursive \
--delete-after \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment