Merge pull request #8314 from mitchellh/sethvargo/cache
Cache on Fastly for a longer time
This commit is contained in:
commit
13593ac4aa
|
@ -48,6 +48,9 @@ if [ -z "$NO_UPLOAD" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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 \
|
s3cmd \
|
||||||
--quiet \
|
--quiet \
|
||||||
--delete-removed \
|
--delete-removed \
|
||||||
|
@ -56,6 +59,7 @@ if [ -z "$NO_UPLOAD" ]; then
|
||||||
--acl-public \
|
--acl-public \
|
||||||
--recursive \
|
--recursive \
|
||||||
--add-header="Cache-Control: max-age=14400" \
|
--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" \
|
--add-header="x-amz-meta-surrogate-key: site-$PROJECT" \
|
||||||
sync "$DIR/build/" "s3://hc-sites/$PROJECT/latest/"
|
sync "$DIR/build/" "s3://hc-sites/$PROJECT/latest/"
|
||||||
|
|
||||||
|
@ -88,7 +92,8 @@ if [ -z "$NO_UPLOAD" ]; then
|
||||||
--recursive \
|
--recursive \
|
||||||
modify "s3://hc-sites/$PROJECT/latest/"
|
modify "s3://hc-sites/$PROJECT/latest/"
|
||||||
fi
|
fi
|
||||||
# Perform a soft-purge of the surrogate key.
|
|
||||||
|
# Perform a purge of the surrogate key.
|
||||||
if [ -z "$NO_PURGE" ]; then
|
if [ -z "$NO_PURGE" ]; then
|
||||||
echo "Purging Fastly cache..."
|
echo "Purging Fastly cache..."
|
||||||
curl \
|
curl \
|
||||||
|
@ -98,7 +103,6 @@ if [ -z "$NO_PURGE" ]; then
|
||||||
--request "POST" \
|
--request "POST" \
|
||||||
--header "Accept: application/json" \
|
--header "Accept: application/json" \
|
||||||
--header "Fastly-Key: $FASTLY_API_KEY" \
|
--header "Fastly-Key: $FASTLY_API_KEY" \
|
||||||
--header "Fastly-Soft-Purge: 1" \
|
|
||||||
"https://api.fastly.com/service/$FASTLY_SERVICE_ID/purge/site-$PROJECT"
|
"https://api.fastly.com/service/$FASTLY_SERVICE_ID/purge/site-$PROJECT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue