3 ms·
I put nginx in front and a location /static/ block with a try_files directive that first tries to serve static files from Django (those collected with python ma
by simonpantzare 11y ago
I put nginx in front and a location /static/ block with a try_files directive that first tries to serve static files from Django (those collected with python manage.py collectstatic) and falls back to serve files that a gulp task generated.
To serve different assets in dev and prod I let gulp generate a manifest and have a custom template tag in Django that expands to different paths depending on settings.DEBUG:
{% my_static 'css/all.css' %}
expands to either /static/css/all.css or something like /static/css/all.min.abcd1234.css.
If nginx is serving a minified, hashed path it adds a Cache-Control: max-age=31556926 header to the response.