3 ms·
One nice thing with Django is that you can separate out truly static files into your apps static folder, and configure nginx to serve the /static/ URL. Configur
by falcolas 13y ago
One nice thing with Django is that you can separate out truly static files into your apps static folder, and configure nginx to serve the /static/ URL. Configure a `STATIC_ROOT` for your app, run:
./manage.py collectstatic
and you have nginx serving the truly static files while still allowing Django to manage your non-static assets.
This is how I run my site, and it works pretty darned well. Let nginx do the caching of static files, compression, and SSL management, letting Django just worry about its small domain of non-static files.
The one downside is that nginx will not necessairly detect when a static file has changed, requiring a bit of effort to ensure that new versions of a static file are puled, either through filename versioning, or `?1` on the end of your static URLs.
- bpicolo 13y agoThat's not unique to Django. You can always send static assets through the web server.
- falcolas 13y agoAbsolutely. But, this being an article on Django, serving a combination of static and semi-static assets, commenting on this Django feature seemed appropriate.
- StavrosK 13y agoIIRC, django-compressor will do that automatically.