I have been testing a bit the HTTP2 server ShimmerCat, and I have set up a reverse proxy on it to use Django. All this has worked like a charm so far, but I have a doubt. Right now I'm serving the Django static files using the approach that Django
has to serve them in development, which means that I have left the settings DEBUG=True
, but as we all know it is not a good practice for production. Is there a way I can use to serve the Django
static files with ShimmerCat
itself?
Here it is the ShimmerCat
config file:
devlove.yaml
:
---
shimmercat-devlove:
domains:
www.mysite.com:
root-dir: site
consultant: 8000
cache-key: xxxxxxxxxxx
api.mysite.com:
port: 8000
Could I use a subdomain
e.g static.mysite.com
to do that? Could the config below be a good solution?
devlove.yaml
:
---
shimmercat-devlove:
domains:
www.mysite.com:
root-dir: site
consultant: 8000
cache-key: xxxxxxxxxxx
static.mysite.com:
root-dir: site/django-app/static
consultant: 8000
cache-key: yyyyyyyyyyy
api.mysite.com:
port: 8000
Of course I would need to do some small changes on the Django
settings, but I know how to handle it. Any help or suggestion will be appreciated. Thanks in advance.
Django Admin pages are generated dynamically. Unfortunately that means that the server can't learn reliably about the assets on those pages and won't be able to use HTTP/2 PUSH to deliver the resources automatically. But electric domains work well as ordinary static domains. So your second option is correct in principle.
However, with HTTP/2 the cost of using cookies should be low enough (HPACK compression should fold them) that you don't need to use a www
and static
domain. You probably are better off by having just one of those domains, say www
:
---
shimmercat-devlove:
domains:
www.mysite.com:
root-dir: site
consultant: 8000
cache-key: xxxxxxxxxxx
api.mysite.com:
port: 8000
This is just your first example! But you need to copy Django's static assets to the site
folder.