From 8cfc7b35968c5b472db50b720c8dbd3cab9bb824 Mon Sep 17 00:00:00 2001 From: nourshoreibah Date: Fri, 16 Oct 2026 21:34:34 -0400 Subject: [PATCH] fix(deploy): send Cache-Control with the frontend build S3 objects had no Cache-Control, so browsers cached HTML and the RSC index.txt payloads heuristically from Last-Modified. After a deploy the new JS fetched an old build's payload from disk cache on client-side navigation (/ -> /dashboard) and the page spun forever. Hashed _next/static assets are now immutable; everything else is no-cache. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/frontend-deploy.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/frontend-deploy.yml b/.github/workflows/frontend-deploy.yml index 52e21f48..43d5e217 100644 --- a/.github/workflows/frontend-deploy.yml +++ b/.github/workflows/frontend-deploy.yml @@ -9,6 +9,7 @@ on: # change to shared/rbac has to redeploy the frontend or the two sides # stop agreeing. - 'shared/rbac/**' + - '.github/workflows/frontend-deploy.yml' workflow_dispatch: # Requires the OIDC apply role (branch-ci-apply) from infrastructure/aws/oidc.tf. @@ -93,7 +94,13 @@ jobs: run: | ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text) echo "BUCKET=branch-frontend-$ACCOUNT_ID" >> "$GITHUB_ENV" - aws s3 sync out "s3://branch-frontend-$ACCOUNT_ID" --delete 2>&1 | tee "$RUNNER_TEMP/sync.log" + # No Cache-Control lets browsers heuristically cache HTML/RSC .txt and pair an old build's payload with new JS. + aws s3 sync out "s3://branch-frontend-$ACCOUNT_ID" --delete \ + --exclude "*" --include "_next/static/*" \ + --cache-control "public, max-age=31536000, immutable" 2>&1 | tee "$RUNNER_TEMP/sync.log" + aws s3 sync out "s3://branch-frontend-$ACCOUNT_ID" --delete \ + --exclude "_next/static/*" \ + --cache-control "no-cache" 2>&1 | tee -a "$RUNNER_TEMP/sync.log" - name: Thread — synced if: success() uses: ./.github/actions/slack-deploy