Skip to content

Commit

Permalink
Bug 1258700 - Generate Brotli-compressed versions of static files
Browse files Browse the repository at this point in the history
WhiteNoise 3.0 now supports serving Brotli-compressed files to browsers
whose `Accept-Encoding` includes `br`. Note: Both Firefox and Chrome
only support Brotli over HTTPS.

To take advantage of this, the Brotli package just needs to be available
when the compression tool (`python -m whitenoise.compress`) is run. See:
http://whitenoise.evans.io/en/latest/changelog.html#brotli-compression-support
http://whitenoise.evans.io/en/latest/django.html#brotli-compression

The WhiteNoise docs say to use an unofficial PyPI package (brotlipy),
however this has a dependency on libffi (via cffi) and the official repo
now has it's own Python wrapper that does not. As such, this commit
instead uses the official Brotli package from GitHub, whilst we wait for
the official PyPI release (google/brotli#72).

The Brotli install works fine on stage/prod/Heroku/Travis. The Vagrant
environment was missing g++, which is now installed during provision.
  • Loading branch information
Ed Morley committed Mar 24, 2016
1 parent 5107906 commit 1aeb69e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions puppet/manifests/classes/python.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"python-dev",
# Required by pylibmc.
"libmemcached-dev",
# Required by Brotli.
"g++",
# To improve the UX of the Vagrant environment.
"git"]:
ensure => "latest",
Expand Down
6 changes: 6 additions & 0 deletions requirements/common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ wsgi-sslify==1.0.1 --hash=sha256:cde368fda0fb9958dd58bc2cb955d0bf3df1b79c132d97c

whitenoise==3.0 --hash=sha256:2537cf2b0c12e1c8beaa23605076344a89d08b686592abffddb6ba13b284a8c6

# Used by the Whitenoise CLI tool to provide Brotli-compressed versions of static files.
# There is not yet an official package on PyPI:
# https://github.com/google/brotli/issues/72
https://github.com/google/brotli/archive/v0.3.0.zip#egg=Brotli==0.3.0 \
--hash=sha256:0e1e88c74b5a4c9c39123fe8adfdce6262c80524398367420475716389d70791

Django==1.8.10 --hash=sha256:471b41cb53d675138475b488c429424ed143e57ad755a2c8ab1206ac30490284

celery==3.1.20 --hash=sha256:3071b71ef8c43178ace8435002b11f2ff06db7690f07d960540eab7f4183ddf7
Expand Down

0 comments on commit 1aeb69e

Please sign in to comment.