Issues

Issue #165 wontfix

Feature request: provide support for cloudfront.(or CDNs in general)

Ioan Alexandru Cucu
created an issue

Many developers using the s3boto backend might also use a CDN for delivering their content. The CDN would be using an S3 bucket as origin.

A simple way of being able to deliver content from a CDN would be to enhance S3BotoStorage.url

My suggestion would be to add two more settings:

  • CDN_DOMAIN
  • USE_CDN

USE_CDN is a callback that would be called in S3BotoStorage.url to determine whether the domain should be the CDN or S3.

If you think this would be an useful feature, I will happily open a pull request.

Comments (7)

  1. syphar

    Isn't the setting AWS_S3_CUSTOM_DOMAIN (in the s3boto-backend) exactly for this case? Files will be uploaded as usual and the generated url is just you custom domain and the path. (will not work if AWS_QUERYSTRING_AUTH is True, should set it to False)

    defined here: https://bitbucket.org/david/django-storages/src/4294a23b33f324df878240d519be005415a914ac/storages/backends/s3boto.py?at=default#cl-224

    used here: https://bitbucket.org/david/django-storages/src/4294a23b33f324df878240d519be005415a914ac/storages/backends/s3boto.py?at=default#cl-467

  2. Ioan Alexandru Cucu reporter

    Agree. But I would like to be able to choose between the S3 domain and the CDN domain based on the result returned by the callback.

    Use case:

    Imagine you upload a new version of a file. It will take a while until the file gets updated on the CDN. Until the file gets updated on the CDN I would like to be able to serve it from S3. Once it's updated, switch back to the CDN.

  3. Ian Lewis

    I got around this by uploading files with a new name so that it would be updated right away on the CDN (cloudfront). You can also manually invalidate the file on cloudfront when you upload a new version.

    In general I think that going back and forth between CDN and S3 is an application specific thing and you should subclass the S3BotoStorage class and override the url() method.

  4. Log in to comment