I'm developing a Drupal 7 website that will be served from multiple servers behind a load balancer.

I want all static files generated by Drupal cache (JS, CSS, and also theme and modules images) to be served via an Amazon S3 bucket.

I already did this for my content types' file upload fields, using the Amazon S3 module, but it's missing the feature I described above.

I saw there's Media Mover module, but it's far from D7 production ready.

What other solutions are there?

  • See Easy Drupal CDN integration for fun and profit by the maintainer of the CDN module.
    – zerolab
    Sep 11, 2012 at 15:07
  • Ok, this sounds like a good start. But I don't use Amazon's CloudFront, I use Akamai. I want to be able to setup Drupal to automatically upload CSS and JS files to a S3 bucket when those are aggregated and generated by Drupal, and then I can use the CDN module to alter the file names to the Akamai domain. Does that make sense?
    – Alon Pe'er
    Sep 11, 2012 at 15:37
  • I haven't had the chance to work with Akamai, but from what I can see it supports both Push and Origin Pull (according to cdnplanet.com/compare/cloudfront/akamai). What you describe sounds like the job of the "File conveyor" mode of the CDN module
    – zerolab
    Sep 12, 2012 at 9:47
  • I was hoping to avoid the complexity of using File Conveyor. I might end up implementing a custom Drupal module in which I'll automatically upload local files from sites/default/files and theme files to S3...
    – Alon Pe'er
    Sep 12, 2012 at 10:27

3 Answers 3


I ended up using the S3AutoPush module. I migrated it to Drupal 7 and hacked the hell out of it to make it fit my needs.

If anyone reads this and is interested, I'd be happy to share my code. I won't put it on drupal.org for now since it's a real hack-job and not worthy yet.

  • Still worth creating a new issue with a patch attached. There is a chance someone else needs it and will get to review the patch and help improve the module
    – zerolab
    Jan 13, 2014 at 11:26
  • Yeah, probably a good idea. It's been a year and the code is live in production, working well. Thanks for the reminder :)
    – Alon Pe'er
    Jan 13, 2014 at 14:20

Other Drupal 7 modules like the File API do this. However I have more experience with the Amazon S3 module.

The Drupal 7 AmazonS3 module still doesn't handle JS/CSS. There is a patch for this, however it's status for the past year has been set to "Needs work", because of the following response by Andrew Berry:

I see a few issues with this patch as-is: 1. It's possible to have two file records for the same file, under different paths. For example, public://bucket/image.jpg and s3://bucket/image.jpg. For managed files, this could lead to data corruption. 2. We had to patch quite a few modules for the S3 wrapper to work properly, since it requires a bucket in the URL. I imagine a ton of modules hardcode public:// file paths without normalizing the URL. 3. There's a performance issue in that S3 can be very slow to create new assets and do an initial stat. For image styles, we basically replaced the style generation with our own code, which is a pain to do for CSS and JS. And, we could have very similar problems with contrib modules.

Anyways, if we can address all of these I'd be interested in getting this in. However, I'm guessing to do this it a way that doesn't break all the things will have to wait for D8.

Speaking of Drupal 8, there is an s3 module by @cweagans that already handles aggregated CSS/JS files as well: https://www.drupal.org/project/flysystem_s3 Hopefully this will be helpful to someone.


It's the good advice that you just didn't take:

Don't place your images/css/js files on Amazon S3 storage since this will complicate the hell out of your Drupal installation, specially when it comes to synchronizing. You'll find a solution for sure, but it will be ugly.

Use a reverse proxy on your static content directly on your production server. You can separate the images/css/js on a separate static subdomain (eg. assets.yourdomain.com). You could utilize Static Server Drupal Module for this.

Use Amazon S3 for a higher purpose, like ec2 snapshot backups, database backups, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.