When it comes time to deploy, one best practice is compressing static assets (js, css), and moving them to a CDN. There are a few Django apps that handle some aspects (django-compressor
, django-pipeline
each come to mind), but they each have their own problems. For example,
django-compressor
wants to generate content inside of the request/response loop, even when exclusively-offline compression is enabled.django-pipeline
doesn't store hashes anywhere, so it iterates through the path it writes compressed files to, regex-matches filenames, sorts those possible matches, and returns the last item in the list. Try doing this from a CDN! What?!The (seemingly logical) pipeline workflow I'm looking for is this:
I shouldn't have to have every static file on all of my web front-end nodes -- only the CDN.
Right now, I feel like my best option is to hack support for caching filename hashes into django-pipeline
, but I'm dreaming of a drop-in solution for this.
What are my best options in Django for this? Are there any?
Thanks!
django-pipeline
1.1.12 is now caching hash, so you should be fine, see the changelog.
Disclaimer: I'm one of the author of django-pipeline
.
Are you running Django 1.3? If so, then you can write your own custom file storage backend that uploads things to a CDN. Luckily, if you want to use Amazon S3, then django-storages
already does exactly what you want!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With