Set far-future cache headers on S3 assets

So that browsers will cache them for as long as possible. We invalidate
this cache by adding the hash of each file to the query string.

There’s no way of doing this on a whole bucket; it has to be set on each
item. Adding this flag does so at the time of uploading the items.

Value of 10 years in seconds taken from:
0ee3bcb1ee/whitenoise/base.py (L19)
This commit is contained in:
Chris Hill-Scott
2018-12-21 11:56:16 +00:00
parent fba9ae0617
commit cc405d7c1a

View File

@@ -99,7 +99,7 @@ upload-paas-artifact:
.PHONY: upload-static ## Upload the static files to be served from S3
upload-static:
aws s3 cp --region eu-west-1 --recursive ./app/static s3://${DNS_NAME}-static
aws s3 cp --region eu-west-1 --recursive --cache-control max-age=315360000,immutable ./app/static s3://${DNS_NAME}-static
.PHONY: test
test: venv ## Run tests