Last active
September 30, 2020 22:47
-
-
Save mraible/0cca15e8340135121f9b to your computer and use it in GitHub Desktop.
Upload optimized assets to Google Cloud Storage
This file contains 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
# Rsync to remove old files | |
gsutil -m rsync -x '.git*' -c -d -r dist gs://bucket/ | |
# Upload and gzip HTML, CSS and JavaScript | |
gsutil -m cp -z "html,css,js" -r dist/** gs://bucket/ | |
# Set expires headers (6 months) on JS and CSS assets | |
gsutil -m setmeta -h "Cache-Control: public, max-age=15552000" gs://bucket/assets/** | |
# Make sure there's no expiration headers on HTML files | |
gsutil -m setmeta -h "Content-Type:text/html" -h "Cache-Control:private, max-age=0, no-transform" gs://bucket/**/*.html |
Still very useful
Many thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this!