From c8445561b30af14c191f0d2c15d0ac2da6a240ca Mon Sep 17 00:00:00 2001 From: Ben Wheeler Date: Tue, 22 Dec 2020 14:18:29 -0500 Subject: [PATCH] set, purge static_assets surrogate key on deploy --- bin/configure-fastly.js | 11 +++++------ package.json | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/bin/configure-fastly.js b/bin/configure-fastly.js index c3eb4cca2..2d3b0c189 100644 --- a/bin/configure-fastly.js +++ b/bin/configure-fastly.js @@ -270,12 +270,11 @@ async.auto({ fastly.activateVersion(results.version, function (e, resp) { if (e) throw new Error(e); process.stdout.write('Successfully configured and activated version ' + resp.number + '\n'); - if (process.env.FASTLY_PURGE_ALL) { - fastly.purgeAll(FASTLY_SERVICE_ID, function (error) { - if (error) throw new Error(error); - process.stdout.write('Purged all.\n'); - }); - } + // purge static_assets using surrogate key + fastly.purgeKey(FASTLY_SERVICE_ID, 'static_assets', function (error) { + if (error) throw new Error(error); + process.stdout.write('Purged static assets.\n'); + }); }); } }); diff --git a/package.json b/package.json index da40221bd..2023d6a8c 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "deploy": "npm run deploy:s3 && npm run deploy:fastly", "deploy:fastly": "node ./bin/configure-fastly.js", "deploy:s3": "npm run deploy:s3:all && npm run deploy:s3:svg && npm run deploy:s3:js", - "deploy:s3cmd": "s3cmd sync -P --delete-removed --add-header=Cache-Control:no-cache,public,max-age=3600", + "deploy:s3cmd": "s3cmd sync -P --delete-removed --add-header=Cache-Control:no-cache,public,max-age=3600 --add-header=Surrogate-Key:static_assets", "deploy:s3:all": "npm run deploy:s3cmd -- --exclude '.DS_Store' --exclude '*.svg' --exclude '*.js' ./build/ s3://$S3_BUCKET_NAME/", "deploy:s3:svg": "npm run deploy:s3cmd -- --exclude '*' --include '*.svg' --mime-type 'image/svg+xml' ./build/ s3://$S3_BUCKET_NAME/", "deploy:s3:js": "npm run deploy:s3cmd -- --exclude '*' --include '*.js' --mime-type 'application/javascript' ./build/ s3://$S3_BUCKET_NAME/",