Since moving to putting the admin app on Cloudfront anything on the

`www.notifications.service.gov.uk` domain is:
- not gzipped

The PaaS proxy used to GZip and set headers for anything served from a
path starting with `/static/`:
76dd511a8a/ansible/roles/paas-proxy/templates/admin.conf.j2 (L53-L64)

Anything served from `static.notifications.service.gov.uk` is:
- GZipped
- and as a bonus, cached by Cloudfront where possible (meaning the
requests won’t ever hit our app)

This commit moves to serving static asset from `/static/` to
`static.notifications.service.gov.uk`, to get the above listed benefits.

***

We could do even better by setting long cache expiry headers on the static subdomain (currently they’re only set to cache for 60 seconds). But that’s out of scope for this commit.
This commit is contained in:
Chris Hill-Scott
2018-11-28 15:39:08 +00:00
parent b872ba21a7
commit b1c0778bde
2 changed files with 6 additions and 1 deletions

View File

@@ -194,7 +194,7 @@ def init_app(application):
@application.context_processor
def inject_global_template_variables():
return {
'asset_path': '/static/',
'asset_path': application.config['ASSET_PATH'],
'header_colour': application.config['HEADER_COLOUR'],
'asset_url': asset_fingerprinter.get_url
}

View File

@@ -74,6 +74,8 @@ class Config(object):
REDIS_URL = os.environ.get('REDIS_URL')
REDIS_ENABLED = os.environ.get('REDIS_ENABLED') == '1'
ASSET_PATH = '/static/'
class Development(Config):
NOTIFY_LOG_PATH = 'application.log'
@@ -117,6 +119,7 @@ class Preview(Config):
MOU_BUCKET_NAME = 'notify.works-mou'
NOTIFY_ENVIRONMENT = 'preview'
CHECK_PROXY_HEADER = False
ASSET_PATH = 'https://static.notify.works/'
class Staging(Config):
@@ -129,6 +132,7 @@ class Staging(Config):
MOU_BUCKET_NAME = 'staging-notify.works-mou'
NOTIFY_ENVIRONMENT = 'staging'
CHECK_PROXY_HEADER = False
ASSET_PATH = 'https://static.staging-notify.works/'
class Live(Config):
@@ -141,6 +145,7 @@ class Live(Config):
MOU_BUCKET_NAME = 'notifications.service.gov.uk-mou'
NOTIFY_ENVIRONMENT = 'live'
CHECK_PROXY_HEADER = False
ASSET_PATH = 'https://static.notifications.service.gov.uk/'
class CloudFoundryConfig(Config):