Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add Cache-Control max-age to CDN files #76

Merged
merged 1 commit into from
Jan 11, 2022

Conversation

qhanam
Copy link
Member

@qhanam qhanam commented Jan 11, 2022

Partially resolves #73 .

This change adds a Cache-Control header to new web client versions deployed to CDN. Specific versions (e.g., 1.0.4) have a max age of one week. Auto-update versions (e.g., 1.0.x and 1.x) have a max age of two hours, so that impact is limited in case a change needs be be rolled back.

Note that browsers typically cache files by default (using a heuristic to estimate TTL), so this change is non-critical.

We still need to add Cache-Control headers to the existing CDN files to fully resolve #73. This will be done by directly modifying the header info of the existing files.

Testing

I ran the deployment workflow in the gamma environment and verified the header cache-control: max-age=604800 is present in 1.0.4/cwr.js, and cache-control: max-age=7200 is present in 1.0.x/cwr.js and 1.x/cwr.js. The Lighthouse recommendation no longer appeared for 1.0.4/cwr.js.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@qhanam qhanam requested a review from anuraaga January 11, 2022 07:30
@@ -3,15 +3,15 @@
version=$(npm pkg get version | sed 's/"//g')
bucket=$1

aws s3api put-object --bucket $bucket --key "content/$version/cwr.js" --body build/assets/cwr.js
aws s3api put-object --bucket $bucket --key "content/$version/LICENSE-THIRD-PARTY" --body LICENSE-THIRD-PARTY
aws s3api put-object --bucket $bucket --key "content/$version/cwr.js" --body build/assets/cwr.js --cache-control max-age=604800

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to set these even longer, like 1 year?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. It's about risk -- what is the likelihood that a specific version will need to be modified?

In theory a version should never change once deployed, but my preference is still to reduce risk, at least for now, by limiting a potential impact to one week instead of one year.

@qhanam qhanam merged commit fad8fb9 into aws-observability:main Jan 11, 2022
@qhanam qhanam deleted the fix-cache-control-max-age branch January 11, 2022 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache cwr.js file from CDN
2 participants