Radically simplified static file serving for Python web apps
open sourceMITfree
WhiteNoise lets a Python web app serve its own static files, so it can be deployed as one self-contained unit without nginx, Amazon S3 or another service in front. In Django you add its middleware and storage backend in a couple of lines of settings; it works with any WSGI app too. It serves gzip and Brotli versions of files with the right Accept-Encoding and Vary headers, and its CompressedManifestStaticFilesStorage hashes file names so responses can carry far-future cache headers. It is designed to sit behind a CDN on high-traffic sites, was first built for Heroku-style platforms, and is MIT licensed.
Problems it solves
- serve Django static files in production without nginx or S3
- my Django CSS and JS return 404 on Heroku after DEBUG=False
- serve compressed static files with long cache headers from a Python app
- put a CDN in front of my Django app's static files
Features
- Django middleware that serves static files from STATIC_ROOT
- works with any WSGI application
- serves gzip and Brotli compressed files with correct Accept-Encoding and Vary headers
- CompressedManifestStaticFilesStorage compresses files and hashes their names
- far-future cache headers for files that won't change
- designed to work behind a CDN
Limitations
- Works with WSGI apps; files must be collected with collectstatic before deploying