whitenoise
whitenoise copied to clipboard
FAQ out of date?
Shouldn’t I be pushing my static files to S3 using something like Django-Storages? No, you shouldn’t. The main problem with this approach is that Amazon S3 cannot currently selectively serve compressed content to your users. Compression (using either the venerable gzip or the more modern brotli algorithms) can make dramatic reductions in the bandwidth required for your CSS and JavaScript. But in order to do this correctly the server needs to examine the Accept-Encoding header of the request to determine which compression formats are supported, and return an appropriate Vary header so that intermediate caches know to do the same. This is exactly what WhiteNoise does, but Amazon S3 currently provides no means of doing this.
Looks like this is out of date. CloudFront supports compressing files, and, since September 2020, supports Brotli compression.
Thanks
@WhyNotHugo What configuration do you currently use to make it work with CloudFront automatically compressing files? Does CloudFront charge you extra when you add compression?
Edit: Nevermind, I found the message from AWS (from September 15th) that using automatic compression is without extra costs. This is good news, I reverted back to the Django ManifestStatiFileStorage (instead of the compressed one) and now the collectstatic command is much faster and also we have much less files on or version control system, making it faster again :+1:
This is good news, I reverted back to the Django ManifestStatiFileStorage (instead of the compressed one) [...]
I missed this comment at the time (there's no email notification if a comment is edited). Thanks for pointing this out, I'm still using CompressedManifestStaticFilesStorage; that's so dumb of me :facepalm:
Does this mean this part of the docs is also outdated? Do I still need to enable brotli in whitenoise via pip install whitenoise[brotli] or is it all taken care of on the CloudFront side?
According to Amazon:
"CloudFront can compress objects using the Gzip and Brotli compression formats. When the viewer supports both formats, CloudFront prefers Brotli."
Does this mean this part of the docs is also outdated?
Yes, a PR for that would be nice. Support for gzip and brotli needs to be enabled on cloudfront too, btw.