|
|
*Note: these are preliminary notes about using Google Cloud Storage as a CDN service*
|
|
|
|
|
|
## Preliminaries
|
|
|
### Preliminaries
|
|
|
|
|
|
* The documentation home is https://developers.google.com/storage/index.
|
|
|
* The main tool is `gsutil`.
|
... | ... | @@ -8,23 +8,30 @@ |
|
|
|
|
|
### Copying
|
|
|
|
|
|
Notes: recursively (-R), compressed (-z), verbose (-v) https://developers.google.com/storage/docs/gsutil/commands/cp
|
|
|
Notes:
|
|
|
|
|
|
gsutil cp -Rzv mathjax gs://mathjax-cdn/
|
|
|
* gsutil option: -m multithreaded (higher load+cost, faster)
|
|
|
* cp options: recursively (-R), compressed (-z), verbose (-v) https://developers.google.com/storage/docs/gsutil/commands/cp
|
|
|
|
|
|
This also works within google storage (which is faster as it does not go through the local machine).
|
|
|
gsutil -m cp -Rzv mathjax gs://mathjax-cdn/
|
|
|
|
|
|
Also of note: `gsutil -m cp -Rzv xyz xyz" -- the `-m` option is for multithreaded/parallel action. This increases costs and decreases performance, but very useful for PNGs...
|
|
|
This also works within google storage, i.e., `gsutil cp gs://bucket1/file1 gs://bucket2/`
|
|
|
|
|
|
### make bucket public
|
|
|
|
|
|
Notes: https://developers.google.com/storage/docs/gsutil/commands/acl#set
|
|
|
Notes:
|
|
|
|
|
|
* should only be needed once
|
|
|
* https://developers.google.com/storage/docs/gsutil/commands/acl#set
|
|
|
|
|
|
gsutil -m setacl -R -a public-read gs://mathjax-cdn
|
|
|
|
|
|
### set CORS
|
|
|
|
|
|
Notes: should only be needed once, https://developers.google.com/storage/docs/cross-origin
|
|
|
Notes:
|
|
|
|
|
|
* should only be needed once
|
|
|
* https://developers.google.com/storage/docs/cross-origin
|
|
|
|
|
|
create XML file with
|
|
|
|
... | ... | @@ -53,17 +60,16 @@ Save as `cors.xml` and run |
|
|
|
|
|
### set headers
|
|
|
|
|
|
Notes: https://developers.google.com/storage/docs/gsutil/commands/setmeta
|
|
|
|
|
|
gsutil setmeta -r -h "Content-Type:font/opentype" -h "Cache-Control:public, max-age=3600" -h "Content-Disposition" gs://mathjax-cdn/mathjax/2.3-latest/fonts/HTML-CSS/TeX/otf/*.otf
|
|
|
|
|
|
EOT and SVG are detected correctly during upload. WOFF is set to the old `x-font/woff`, so needs changing (and a bug report at Google).
|
|
|
Notes:
|
|
|
|
|
|
Note: unfortunately we can't just use something like gs//mathjax-cdn/*.otf
|
|
|
* https://developers.google.com/storage/docs/gsutil/commands/setmeta
|
|
|
* keep the `**` to match files in subdirectories https://developers.google.com/storage/docs/gsutil/addlhelp/WildcardNames
|
|
|
* EOT and SVG `content-type` headers are detected correctly during upload.
|
|
|
* WOFF is set to the old mime type `x-font/woff`; that works but we decided to go with the future-proof
|
|
|
* bug report at Google?
|
|
|
|
|
|
or can we? https://developers.google.com/storage/docs/gsutil/addlhelp/WildcardNames)
|
|
|
gsutil setmeta -r -h "Content-Type:font/opentype" -h "Cache-Control:public, max-age=3600" -h "Content-Disposition" gs://mathjax-cdn/mathjax/2.3-latest/fonts/HTML-CSS/**.otf
|
|
|
|
|
|
Yes. E.g. ``gsutil ls gs://mathjax-cdn/mathjax/2.3-latest/fonts/HTML-CSS/**.woff`` will list all woff files in subfolders.
|
|
|
|
|
|
## TODO
|
|
|
|
... | ... | |