Off-loading wpmu theme files to Amazon-S3

I saw a few people looking for solutions to off-load wpmu files to Amazon-S3 service. This is something we wanted to try on our installation (just a few thousand blogs) so I wrote a plugin that will serve themes css and image files from S3.

The plugin uses the ‘stylesheet_directory_uri‘ filter to set the stylesheet uri (css file). In turn, the stylesheet uses the ‘url‘ method to call the image files of the theme so they get the same base url as the stylesheet. Most themes uses the ‘stylesheet_directory‘ call correctly so you will not run into trouble but if a theme uses it to call a php file you should change the call to use ‘template_directory‘.



  1. Signup for an Amazon-S3 account.
  2. Create a bucket for your files. Since you have to select a globally unique name for your buckets I call it were is my wpmu installation.
  3. To point s3 to your bucket setup a CNAME record: s3 -> (don’t forget that extra dot at the end).
  4. Load your themes css and image files to your bucket keeping the exact directory structure for each theme (/wp-contents/themes/… ). You can use the excellent S3 FireFox Organizer to mange your files.
  5. Edit the plugin to include your bucket name.
  6. Place the plugin in the mu-plugins directory.
  7. Test, test and test all your themes!

Whats next? The next step I’m planning is to off-load the Java Scripts in the wp-includes folder. Also planned is an option to serve the users files from S3. If you are interested in helping in any way please leave a comment and we can take it from there.

Did you find this post interesting? Please subscribe to my feed.

Comments 21

  1. Hone wrote:

    Great idea. Offloading the wp-includes statics to s3 is something I already done but I didn’t do it as a plugin and just hardcoded it in.

    Posted 13 Apr 2008 at 3:08 am
  2. Elad wrote:

    Hone, I rather not hardcode things in the core files. Would you like to share the changes you made?

    Posted 13 Apr 2008 at 6:31 am
  3. suleiman wrote:

    notice any speedboost?

    Posted 14 Apr 2008 at 6:20 am
  4. Elad wrote:

    I would not say speedboost but this is one of the measures we take to reduce the stress on the server (caching would be anther one).

    btw, your home page is great, did you share your nice mootools effects ?)

    Posted 14 Apr 2008 at 6:37 am
  5. suleiman wrote:


    Thanks for the kind words. I haven’t shared my homepage, at least not in a nice downloadable form, primarily because it’s not pretty code. You can of course download all of the necessary scripts to make those funky animations from the mootools homepage.

    With respect to speedboosts, I’ve been working hard on optimizing my site load times over the past couple of weeks, including setting up APC, wp-super-cache, and boosting mysql cache. My next step is to try and figure out how to get gzip encoding to work. Have you had any luck with that?

    Posted 14 Apr 2008 at 5:15 pm
  6. Elad wrote:

    For caching we use super-cache. I did made a hack so the cache will be cleared when a user updates his widgets.

    Why would go want to gzip? This may save you bandwidth but that is not an issue, or is it?

    Posted 14 Apr 2008 at 8:37 pm
  7. Hone wrote:

    Elad, I didn’t really make notes.

    I set up an s3 bucket an cnamed a subdomain there like

    Then I did a find and replace in script-loader.php and placed the subdomain before every .js file.

    It’s a pretty sucky way of doing it. But it only took me a minute to change the file with find and replace.

    With Nginx you can actually set it up to proxy any requests to /wp-includes/js/ to an s3 bucket. That way it appears as though your javascript is coming from when really its being served by an s3 bucket.

    Posted 20 Apr 2008 at 10:00 am
  8. suleiman wrote:

    Elad, just to update you, I did end up getting GZIP compression working. Not only does it cut down on bandwidth requirements, but it also boosts page load time by 2-3 times. I strongly recommend it.

    Posted 21 Apr 2008 at 12:52 am
  9. Elad wrote:

    Suleiman, sounds great!
    How did you do it? Is it with the super-cache plugin settings?

    Posted 21 Apr 2008 at 6:34 am
  10. Adam wrote:

    How about uploading all the user submitted files to s3?

    That is where most of my storage is … freakin user’s uploading massive pictures.

    Posted 21 May 2008 at 5:11 am
  11. Elad wrote:

    Adam, users are always the problem but I’m not there yet.

    Posted 21 May 2008 at 6:27 am
  12. ovidiu wrote:

    I see some asked about a plugin to submit all user data to S3. I found such a plugin although I haven’t tested it yet, and I ma unsure how it will work with wpmu although its advertised to work with wpmu…

    Posted 07 Sep 2008 at 2:15 am
  13. Dr. Mike Wendell wrote:

    I was just coming by to point you at the same plugin. Haven’t tried it myself as I don’t have a working credit card but it does say it will work with mu.

    Posted 23 Sep 2008 at 10:23 pm
  14. ovidiu wrote:

    I had a closer look at the plugin I mentioned, and found a sample configuration file. It seems you can pre configure the values to be used for wpmu there and that should make it run as a wpmu plugin as opposed to its normal usage under wp.

    Posted 02 Oct 2008 at 4:38 pm
  15. Dr. Mike Wendell wrote:

    Thanks for the follow up. I still haven’t tried it myself although it is on the to do list. I noted that it replaces the local storage tab which would work for us. I’d call it something else though beside Amazon. That would just confuse folks.

    Maybe after Christmas. I do have a couple of clients asking about this. Our servers don’t have that much load though and we’re moving all of our mu installs onto their own boxes anyway.

    The pixel audio plugin got a fix to use amazon as well.

    Posted 10 Oct 2008 at 4:37 am
  16. Jed wrote:

    Anyone tried to look up on SimpleCDN instead Amazon for the plugin?

    Posted 10 Feb 2009 at 5:50 pm
  17. pete wrote:

    I want to use this plugin to allow all blog users to store their images in one amazon s3 account.
    And video for streaming.
    Can this be done?

    Posted 06 Mar 2009 at 11:34 pm
  18. Elad wrote:

    pete – not with this plugin.

    Posted 08 Mar 2009 at 7:48 am
  19. sean wrote:

    I was hoping this was about being able to post amazon links like is squidoo in WPMU.


    Posted 13 May 2009 at 12:29 pm
  20. wrote:

    i just use .htaccess to redirect everything (except php) in wp-content and wp-includes to cdn

    Posted 23 May 2009 at 9:55 am
  21. Elad wrote:

    The thing with using .htaccess redirect is that your server is getting all the hits.

    Posted 24 May 2009 at 7:24 am

Trackbacks & Pingbacks 7

  1. From Links for 2008-04-30 [] | RedMallorca LAB on 04 May 2008 at 2:21 am

    […] Off-loading wpmu theme files to Amazon-S3 | Ring Of Blogs […]

  2. From First month data using S3 offloading for WPMU | Ring Of Blogs on 08 May 2008 at 8:35 am

    […] Ring Of Blogs blogging, wordpress-MU, monetization and stuff… « Off-loading wpmu theme files to Amazon-S3 […]

  3. From My Worklog » Post Topic » Links for 24-Sep-2008…. wordpress & wikis on 24 Sep 2008 at 4:59 am

    […] Off-loading wpmu theme files to Amazon-S3. […]

  4. From Scaling your WordPress MU and BuddyPress installation | LightSpeed on 13 Aug 2009 at 12:04 pm

    […] your themes to Amazon S3 to distribute server load (like – Utilise a WordPress MU plugin to unload our Themes to Amazon […]

  5. From Off-loading wpmu theme files to Amazon-S3 | Ring Of Blogs « Random Messages on 10 Dec 2009 at 7:36 am

    […] Off-loading wpmu theme files to Amazon-S3 | Ring Of Blogs. tags: amazon, aws, s3 storage, wordpress, wordpress mu older » BRRR..Snow in Montpelier » No Responses to "Off-loading wpmu theme files to Amazon-S3 | Ring Of Blogs". Add a comment? or Follow comments by RSS? Be the first and share your thoughts! […]

  6. From links for 2009-07-13 | blog/shl@INTERDOSE on 22 Dec 2009 at 2:02 pm

    […] Off-loading wpmu theme files to Amazon-S3 | Ring Of Blogs (tags: wordpress) […]

  7. From S3 Explorer review | Ring Of Blogs on 14 Feb 2010 at 4:59 pm

    […] using Amazon web services for some time now. I have started with Amazon Simple Storage (S3) for off-loading WPMU theme files and later on started using it for daily backup of all my web sites and blogs. The backup is […]

Post a Comment

Your email is never published nor shared. Required fields are marked *