From cc405d7c1a1202833583e7df45762092c5559ce5 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 21 Dec 2018 11:56:16 +0000 Subject: [PATCH] Set far-future cache headers on S3 assets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: https://github.com/evansd/whitenoise/blob/0ee3bcb1eebdf4cada9024a858fa086d3dac6561/whitenoise/base.py#L19 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4a47ac509..6b6c3554e 100644 --- a/Makefile +++ b/Makefile @@ -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