Skip to content

Commit 1b1c4b5

Browse files
authored
Enable gzip compression on GCS for our hosted examples (#238)
- Enable gzip compression on our example assets - Enable caching (remove the no-cache: private header) - Remove the old `dist/` files so we do not accumulate multiple versions. - Re-uploaded each example by running the `deploy.sh` script This saves everyone **significant** bandwidth (both GCP and the user). Verified the improvement on PageSpeed Insights: [See addition-rnn as example](https://developers.google.com/speed/pagespeed/insights/?url=https%3A%2F%2Fstorage.googleapis.com%2Ftfjs-examples%2Faddition-rnn%2Fdist%2Findex.html)
1 parent f979101 commit 1b1c4b5

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

deploy.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,11 @@ for i in $EXAMPLES; do
4646

4747
echo "building ${EXAMPLE_NAME}..."
4848
yarn
49+
rm -rf dist .cache
4950
yarn build
50-
gsutil mkdir -p gs://tfjs-examples/$EXAMPLE_NAME
51-
gsutil mkdir -p gs://tfjs-examples/$EXAMPLE_NAME/dist
52-
gsutil -m cp dist/* gs://tfjs-examples/$EXAMPLE_NAME/dist
51+
# Remove the example directory.
52+
gsutil -m rm -r gs://tfjs-examples/$EXAMPLE_NAME
53+
# Gzip and copy all the dist files. The trailing slash is important.
54+
gsutil -m cp -Z -r dist gs://tfjs-examples/$EXAMPLE_NAME/
5355
cd ..
5456
done
55-
56-
gsutil -m setmeta -h "Cache-Control:private" "gs://tfjs-examples/**.html"
57-
gsutil -m setmeta -h "Cache-Control:private" "gs://tfjs-examples/**.css"
58-
gsutil -m setmeta -h "Cache-Control:private" "gs://tfjs-examples/**.js"

0 commit comments

Comments
 (0)