whitenoise icon indicating copy to clipboard operation
whitenoise copied to clipboard

FAQ out of date?

Open WhyNotHugo opened this issue 5 years ago • 5 comments

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.

WhyNotHugo avatar Nov 01 '20 09:11 WhyNotHugo

Thanks

evansd avatar Nov 02 '20 09:11 evansd

@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:

gabn88 avatar Nov 25 '20 12:11 gabn88

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:

WhyNotHugo avatar Feb 27 '21 16:02 WhyNotHugo

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."

Jsalaz1989 avatar Nov 29 '21 19:11 Jsalaz1989

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.

WhyNotHugo avatar Dec 02 '21 10:12 WhyNotHugo