Commit dd6ee0ad authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

SuperSize: Set no-cache headers for hosted version

Turns out google storage sets a one hour public cache header by default,
which means a bad push results in the page being broken for an hour.

This leaves the default header on for .size files, but sets all other
files (which are tiny) to no-cache.

Note: the .wasm file is big, and should probably be cached, but that is handled
by the service worker already.

Bug: None
Change-Id: Ia3c03e4533c37338b924d5ace3f7b5fd4ac8d6f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1981263
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarEric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727618}
parent 7fa9ab8b
...@@ -231,6 +231,10 @@ def main(): ...@@ -231,6 +231,10 @@ def main():
if args.sync: if args.sync:
subprocess.check_call(cmd) subprocess.check_call(cmd)
subprocess.check_call([
'gsutil.py', 'setmeta', '-h', 'Cache-Control:no-cache',
_PUSH_URL + 'milestones.json'
])
else: else:
print() print()
print('Sync files by running:') print('Sync files by running:')
......
...@@ -71,7 +71,10 @@ def main(): ...@@ -71,7 +71,10 @@ def main():
with tempfile.NamedTemporaryFile() as f: with tempfile.NamedTemporaryFile() as f:
_WriteReportsJson(f) _WriteReportsJson(f)
cmd = ['gsutil.py', 'cp', '-a', 'public-read', f.name, _REPORTS_JSON_GS_URL] cmd = [
'gsutil.py', '--', '-h', 'Cache-Control:no-cache', 'cp', '-a',
'public-read', f.name, _REPORTS_JSON_GS_URL
]
logging.warning(' '.join(cmd)) logging.warning(' '.join(cmd))
subprocess.check_call(cmd) subprocess.check_call(cmd)
......
...@@ -18,7 +18,8 @@ def _SyncStatic(): ...@@ -18,7 +18,8 @@ def _SyncStatic():
"""Upload static files from the static directory.""" """Upload static files from the static directory."""
static_files = os.path.join(os.path.dirname(__file__), 'static') static_files = os.path.join(os.path.dirname(__file__), 'static')
subprocess.check_call([ subprocess.check_call([
'gsutil.py', '-m', 'rsync', '-r', static_files, GS_BUCKET 'gsutil.py', '--', '-m', '-h'
'Cache-Control:no-cache', 'rsync', '-r', static_files, GS_BUCKET
]) ])
...@@ -28,8 +29,10 @@ def _SyncTemplates(): ...@@ -28,8 +29,10 @@ def _SyncTemplates():
cache_hash = uuid.uuid4().hex cache_hash = uuid.uuid4().hex
p = subprocess.Popen([ p = subprocess.Popen([
'gsutil.py', 'cp', '-p', '-', '%s/sw.js' % GS_BUCKET 'gsutil.py', '--', '-h'
], stdin=subprocess.PIPE) 'Cache-Control:no-cache', 'cp', '-p', '-', GS_BUCKET + '/sw.js'
],
stdin=subprocess.PIPE)
with open(template_file, 'r') as in_file: with open(template_file, 'r') as in_file:
p.communicate(in_file.read().replace('{{cache_hash}}', cache_hash)) p.communicate(in_file.read().replace('{{cache_hash}}', cache_hash))
...@@ -42,9 +45,8 @@ def _SetMetaAndPermissions(): ...@@ -42,9 +45,8 @@ def _SetMetaAndPermissions():
]) ])
# All files in the root of the bucket are user readable # All files in the root of the bucket are user readable
subprocess.check_call([ subprocess.check_call(
'gsutil.py', '-m', 'acl', 'ch', '-u', 'AllUsers:R', '%s/*' % GS_BUCKET ['gsutil.py', '-m', 'acl', 'ch', '-u', 'AllUsers:R', GS_BUCKET + '/*'])
])
def main(): def main():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment