Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7069039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:23:51+00:00 2026-05-28T05:23:51+00:00

I want to serve my compressed CSS/JS from CloudFront (they live on S3), but

  • 0

I want to serve my compressed CSS/JS from CloudFront (they live on S3), but am unable to work out how to do it via the compressor settings in settings.py, I have the following:

    COMPRESS_OFFLINE = True 
    COMPRESS_URL = 'http://static.example.com/' #same as STATIC_URL, so unnecessary, just here for simplicity
    COMPRESS_STORAGE = 'my_example_dir.storage.CachedS3BotoStorage' #subclass suggested in [docs][1]
    COMPRESS_OUTPUT_DIR = 'compressed_static'
    COMPRESS_ROOT = '/home/dotcloud/current/static/' #location of static files on server

Despite the COMPRESS_URL, my files are being read from my s3 bucket:

<link rel="stylesheet" href="https://example.s3.amazonaws.com/compressed_static/css/e0684a1d5c25.css?Signature=blahblahblah;Expires=farfuture;AWSAccessKeyId=blahblahblah" type="text/css" />

I guess the issue is I want to write the file to S3, but read it from CloudFront. Is this possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:23:51+00:00Added an answer on May 28, 2026 at 5:23 am

    I wrote a wrapper storage backend around the one provided by boto

    myapp/storage_backends.py:

    import urlparse
    from django.conf import settings
    from storages.backends.s3boto import S3BotoStorage
    
    def domain(url):
        return urlparse.urlparse(url).hostname    
    
    class MediaFilesStorage(S3BotoStorage):
        def __init__(self, *args, **kwargs):
            kwargs['bucket'] = settings.MEDIA_FILES_BUCKET
            kwargs['custom_domain'] = domain(settings.MEDIA_URL)
            super(MediaFilesStorage, self).__init__(*args, **kwargs)
    
    class StaticFilesStorage(S3BotoStorage):
        def __init__(self, *args, **kwargs):
            kwargs['bucket'] = settings.STATIC_FILES_BUCKET
            kwargs['custom_domain'] = domain(settings.STATIC_URL)
            super(StaticFilesStorage, self).__init__(*args, **kwargs)
    

    Where my settings.py file has…

    STATIC_FILES_BUCKET = "myappstatic"
    MEDIA_FILES_BUCKET = "myappmedia"
    STATIC_URL = "http://XXXXXXXX.cloudfront.net/"
    MEDIA_URL = "http://XXXXXXXX.cloudfront.net/"
    
    DEFAULT_FILE_STORAGE = 'myapp.storage_backends.MediaFilesStorage'
    COMPRESS_STORAGE = STATICFILES_STORAGE = 'myapp.storage_backends.StaticFilesStorage'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to serve my css and images from a static cookieless domain. Now
I want so serve some videos on my site. They are available as .MP4
I want spring to serve certain files from the /tmp... directory, the specific directory
On my web site I want to serve user a page with a lot
Say I have a web service where I want to serve the content only
I run PHP 5.2 on Ubuntu with Apache 2. When I want to serve
I'm trying to cache Python/flask responses with memcached. I then want to serve the
I have an admin module and I want it to serve dynamic controllers, i.e.
I want to use a single Doctrine install on our server and serve multiple
I have map.resources :posts and I want to be able to serve post bodies

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.