From 68eb48afff166f8d4418b04bd12f7ee81906ed7a Mon Sep 17 00:00:00 2001 From: Luke Burden Date: Wed, 24 Jun 2020 23:10:39 -0700 Subject: [PATCH 1/2] Add Amazon CloudFront config to ensure serving of pre-compressed gzip files --- docs/django.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/django.rst b/docs/django.rst index 8fb2d196..14871910 100644 --- a/docs/django.rst +++ b/docs/django.rst @@ -177,6 +177,20 @@ For apps on Heroku, you'd run this command search results. You can restrict CloudFront to only proxy your static files by following :ref:`these directions `. +.. using compression algorithms other than gzip:: + + By default, CloudFront will discard any ``Accept-Encoding`` header browsers include + in requests, unless the value of the header is gzip. If it is gzip, CloudFront will + fetch the uncompressed file from the origin, compress it, and return it to the + requesting browser. + + To get CloudFront to not do the compression itself as well as serve files compressed + using other algorithms, such as Brotli, you must configure your distribution to + `cache based on the Accept-Encoding header`__. You can do this in the ``Behaviours`` + tab of your distribution. + +.. __: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html#compressed-content-custom-origin + .. _runserver-nostatic: From 89b7c82819d8934bb92785f82585149e131481b1 Mon Sep 17 00:00:00 2001 From: David Evans Date: Wed, 29 Jul 2020 10:30:36 +0100 Subject: [PATCH 2/2] Fix ReST syntax in docs --- docs/django.rst | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/docs/django.rst b/docs/django.rst index 14871910..4e231982 100644 --- a/docs/django.rst +++ b/docs/django.rst @@ -170,6 +170,21 @@ For apps on Heroku, you'd run this command heroku config:set DJANGO_STATIC_HOST=https://d4663kmspf1sqa.cloudfront.net +Using compression algorithms other than gzip +++++++++++++++++++++++++++++++++++++++++++++ + +By default, CloudFront will discard any ``Accept-Encoding`` header browsers include +in requests, unless the value of the header is gzip. If it is gzip, CloudFront will +fetch the uncompressed file from the origin, compress it, and return it to the +requesting browser. + +To get CloudFront to not do the compression itself as well as serve files compressed +using other algorithms, such as Brotli, you must configure your distribution to +`cache based on the Accept-Encoding header`__. You can do this in the ``Behaviours`` +tab of your distribution. + +.. __: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html#compressed-content-custom-origin + .. note:: By default your entire site will be accessible via the CloudFront URL. It's @@ -177,20 +192,6 @@ For apps on Heroku, you'd run this command search results. You can restrict CloudFront to only proxy your static files by following :ref:`these directions `. -.. using compression algorithms other than gzip:: - - By default, CloudFront will discard any ``Accept-Encoding`` header browsers include - in requests, unless the value of the header is gzip. If it is gzip, CloudFront will - fetch the uncompressed file from the origin, compress it, and return it to the - requesting browser. - - To get CloudFront to not do the compression itself as well as serve files compressed - using other algorithms, such as Brotli, you must configure your distribution to - `cache based on the Accept-Encoding header`__. You can do this in the ``Behaviours`` - tab of your distribution. - -.. __: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html#compressed-content-custom-origin - .. _runserver-nostatic: