Created
January 6, 2020 13:27
-
-
Save tboock/943923d00e6dbf5a608bec16e210fa2b to your computer and use it in GitHub Desktop.
Enable client-side caching for files *after* deployment. Useful if you are hit by https://github.com/aws/aws-cdk/issues/4665.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| function enable_caching { | |
| ttl="$1" | |
| shift | |
| for dir in "${@}" | |
| do | |
| aws s3 cp \ | |
| --metadata-directive REPLACE \ | |
| --cache-control "max-age=$ttl" \ | |
| --recursive \ | |
| "s3://some-bucket/$dir/" \ | |
| "s3://some-bucket/$dir/" | |
| done | |
| } | |
| enable_caching 86400 "css" "js" | |
| enable_caching 31536000 "fonts" "img" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment