From 0724336f6b46a9deef10bd43740323d394465690 Mon Sep 17 00:00:00 2001 From: Nara Kim Date: Tue, 8 Sep 2026 09:40:32 -0400 Subject: [PATCH] chore: shorten tokenlist CDN cache and invalidate it after upload --- .github/workflows/update-caip-map.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-caip-map.yml b/.github/workflows/update-caip-map.yml index 1024f29db1..750b4b5139 100644 --- a/.github/workflows/update-caip-map.yml +++ b/.github/workflows/update-caip-map.yml @@ -40,5 +40,16 @@ jobs: - name: Upload to S3 run: | echo "Uploading tokenlist to S3..." - aws s3 cp metamask-uniswap-tokenlist.json s3://${{ env.S3_BUCKET_NAME }}/${{ env.S3_PATH }} --cache-control "max-age=3600" + aws s3 cp metamask-uniswap-tokenlist.json s3://${{ env.S3_BUCKET_NAME }}/${{ env.S3_PATH }} --cache-control "max-age=300" echo "Upload complete" + + # Downstream syncs (tokens api) poll this file every 20 minutes; without an + # invalidation a merged token only reaches them once the CDN copy expires. + # Requires the STATIC_CF_DISTRIBUTION_ID repository variable and + # cloudfront:CreateInvalidation on the S3 role; skipped until both exist. + - name: Invalidate CDN cache + if: ${{ vars.STATIC_CF_DISTRIBUTION_ID != '' }} + run: | + echo "Invalidating /${{ env.S3_PATH }} on distribution ${{ vars.STATIC_CF_DISTRIBUTION_ID }}..." + aws cloudfront create-invalidation --distribution-id "${{ vars.STATIC_CF_DISTRIBUTION_ID }}" --paths "/${{ env.S3_PATH }}" + echo "Invalidation requested"