From 5861ad0fefe67fc5c40c46069c0aa337745eda8e Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Fri, 17 Nov 2017 15:56:30 +0200 Subject: Update MIME types and cache headers --- cron/.gitignore | 5 ++++- cron/handler.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cron/.gitignore b/cron/.gitignore index 84c61a9..22e4d37 100644 --- a/cron/.gitignore +++ b/cron/.gitignore @@ -16,5 +16,8 @@ var/ .installed.cfg *.egg +__pycache__ +*.pyc + # Serverless directories -.serverless \ No newline at end of file +.serverless diff --git a/cron/handler.py b/cron/handler.py index 100041e..64f96e8 100644 --- a/cron/handler.py +++ b/cron/handler.py @@ -37,7 +37,7 @@ def geshem_update(): if latest_keys: if key not in latest_keys: - client.put_object(Bucket=BUCKET, Key=key, Body=img) + client.put_object(Bucket=BUCKET, Key=key, Body=img, ContentType='image/png', CacheControl='public, max-age=31536000') latest_keys.append(key) response += 'Put {}, '.format(key) else: @@ -57,7 +57,7 @@ def geshem_update(): keys = sorted(list(filter(lambda k: k.endswith('{}.png'.format(r)), latest_keys)))[-10:] index[r] = keys client.put_object(Bucket=BUCKET, Key='imgs.json', Body=json.dumps(index), - ContentType='application/json', Expires=datetime.utcnow() + timedelta(minutes=1)) + ContentType='application/json', CacheControl='public, max-age=60') return response -- cgit v1.3.1