clintonb / cookiecutter-django

Cookiecutter template for Django projects
MIT License
7 stars 1 forks source link

Fix static and media file servicing #6

Open clintonb opened 5 years ago

clintonb commented 5 years ago

Media files should go to a cloud provider (e.g. S3). django-storages should solve this problem.

If the application is behind a CDN (e.g. CloudFront), the webserver (nginx) can serve static files and rely on the CDN to cache them. While we can use S3 to store the files, doing so might be a bit more cumbersome at deployment time with the need to run collectstatic after each deployment. There is also no good way to cleanup old files over time.

Remaining Work

clintonb commented 5 years ago

WhiteNoise seems to achieve what I want:

  1. Serve files from Django with custom hash.
  2. Put CloudFront in front of web server to handle caching.