Invalidate dev CloudFront

export AWS_PROFILE=default
DIST=E200VHSCVLY8TL
 
ID=$(aws cloudfront create-invalidation --distribution-id $DIST --paths '/*' \
      --query 'Invalidation.Id' --output text)
 
until [ "$(aws cloudfront get-invalidation --distribution-id $DIST --id "$ID" \
           --query 'Invalidation.Status' --output text)" = Completed ]; do
  sleep 15
done
echo "done"

Usually completes in well under a minute.

Paths with special characters

Webpack filenames contain ~, which the CLI rejects when passed literally as an invalidation path. Use a wildcard instead of naming the file:

--paths '/js/*'          # works
--paths '/js/app~0e6551fc.875fa3bb.js'   # InvalidArgument

Confirm you’re seeing fresh content

curl -sSI https://dev.villamarket.net/js/app~0e6551fc.875fa3bb.js \
  | grep -iE 'x-cache|etag|age'

x-cache: Miss from cloudfront right after an invalidation is expected and means the edge refetched from S3.

Invalidating is often not the fix

For frontend assets the service worker precache sits in front of the browser and ignores CloudFront entirely. If testers still see old behaviour after a completed invalidation, you need patch-dev-web-bundle rather than another invalidation.