How to use SimpleCDN with WordPress

Update 2/24/2009: This method is deprecated. I wrote a plugin to rewite urls.
Update again: SimpleCDN is slower comparing to CloudFront, I moved all my link to CF. If you have problem copying files to S3, you can read this post.

WordPress is my favorite bloging software, with many builtin features and powerful plugins. WordPress.com, the blogging platform by automattic, has been using CDN for a long time. However there is no public available solution to make self hosted WordPress to use a CDN as well. Fortunately the php code itself is very clean to read, so it took me about 5 minutes to find where I should modify to fully integrate my new CDN address.

Before you proceed, please read my previous posts on how to use CNAME with SimpleCDN and how to process javascript and css files for WordPress. Make sure your SimpleCDN’s CNAME and bucket working properly. I used a mirror bucket which points to my blog address, that is probably the simplest way to mirror your static assets. And use ‘-s1′ pre-url to insure client side cache working, because SimpleCDN does not use 304 not modified http header at all. I used bucket name ‘s.mudy.info’ for my own blog.

Once your DNS full propagated, open your favorite text editor open following 3 files.

wp-includes/class.wp-scripts.php‘: near line 75, change

$src = $this->base_url . $src;

to

$src = 'http://yourcdnbucketname' . $src;

There is no trailing slash after your bucketname. If you want to make sure client browser always use cached version, you can also comments out the following line.

// $src = add_query_arg('ver', $ver, $src);

But this change may break WordPress upgrade.

wp-include/class.wp-styles.php‘: near line 79, do the same change as above.

wp-include/theme.php‘: near line 504, change

return apply_filters('theme_root_uri', content_url('themes'), get_option('siteurl'));

to

return 'http://yourcdnbucketname/wp-content/themes';

That’s it. Now clean your cache and test your blog.

  • http://www.navelfluff.org Robin Laurén

    Hello and thanks for your posting!

    I was pleasantly surprised to see how easy it is to get started with SimpleCDN. Thanks!

  • Pingback: I wrote a WP plugin | Mudy's Blog

  • radu

    can you give us a little tutorial on how did you made everything work out ?
    can we create a bucket on the public_html folder example

    bucketname : blogcdn.xxx.com
    url : http://xxx.com
    ?

  • radu

    @Yejun
    Oh … and about the subdomain that I made

    I’ve made it like this cdnfiles.your-hairstyles.com and root folder for the subdomain /public_html/

  • radu

    Hi Yejun
    so let me explain exactly what I did :
    1 . I installed the blog into my public_html/ ( root folder )
    2 created a subdomain ( cdnfiles.your-hairstyles.com )
    3 created a mirror bucket
    a) Mirror Bucket Name: cdnfiles
    b) Origin Server URL: http://your-hairstyles.com
    c) Service / Pricing: storm front delivery
    4 made modification into my /var/named/your-hairstyles.com.db
    ( cdnfiles IN CNAME cdnfiles-s1.simplecdn.net.

  • radu

    ping cdnfiles.your-hairstyles.com
    PING cdnfiles-s1.simplecdn.net (208.92.68.58) 56(84) bytes of data.
    64 bytes from 208-92-68-58.global.simplecdn.net (208.92.68.58): icmp_seq=1 ttl=56 time=37.4 ms

  • radu

    Can you please email me if you have some time to chat ? I would also need some advice

    Thanks

    • Yejun

      Your bucket name is wrong. It has to be ‘cdnfiles.your-hairstyles.com’ not just ‘cdnfiles’.

  • radu

    Bucket Creation Error:
    Bucket names may only contain lowercase characters, numbers and/or periods.
    I cannot use – in bucket name only lowercase and numbers

  • radu
    • Yejun

      1. You didn’t CNAME cdnfiles.your-hairstyles.com
      2. Simplecdn does not support php file.

  • radu

    So you are right about the bucket name but my problem is that my domain has a – :) do you have any idea what should I do ?
    than

    • Yejun

      You still can use bucket.simplecdn.net or register a new domain.

  • http://www.simplecdn.com Frank Wilson

    Our new Lightning service should take care of this issue; we can now map *any* CNAME to your bucket, so the name you give your bucket really doesn’t matter if you are going to be using a CNAME.

    Lightning is a *clone* of Amazon CloudFront, and behaves the exact same way (except edge cache expiration can be set as low as 6 hours, instead of a 24 hour minimum like CF), and obviously you can use any HTTP server as the origin, instead of just S3. The service is in public beta, and you can try it out for free.

    Thanks,

    Frank Wilson, Chief Engineer
    SimpleCDN Technologies, Inc.

  • Steven

    Hey frank, what about speed now? The blogger said SimpleCDN was slower then CF, are you guys fixing that?

  • http://www.simplecdn.com Frank Wilson

    Yes… with our new partnership with Highwinds we are expanding our network and locations, especially for our new Lightning service. With the exception of Asia (we are not there and ready to go until fall), you can expect Lightning to be equal to CloudFront (or better) in about a month (mid June) when all of our POPs have Lightning edge nodes.

    We have also just added HTTPS support to Lightning, and the ability to select down to a 3 hour cache expiration, or up to 7 days.

    Thanks,

    Frank

  • Everton Wallace

    SimpleCDN is deceptive; you can test their service, but they start charging you for storage on what you think is an evaluation account.

    Then I found out about a respected consultant who was sending them a customer — SimpleCDN said that he was a hacker, and that he owed them thousands, and that he was being reported to law enforcement. It turned out to be a lie. Hmmmm. They even encouraged a client to dump the consultant that referred them to SimpleCDN! The publisher of the leading industry magazine was also attacked by SimpleCDN’s employee (Robyn) when he exposed them as the CDN that gets the majority of complaints.

    Any company that would attack consumer testers or reviewers is dangerous. SimpleCDN is rogue. Frank Wilson should be put in jail along with the Enron and mciWorldCom dirtbags. Stay away from this company — they will find a way to rip you off, destroy your live event, disrupt your business or slander your name.

  • http://conjur.com.br Iuri

    We started using SimpleCDN’s service before they changed their usage plans. In their system you have to pay upfront for the service; you have an account and they deduce your usage from what you’ve deposited. When they changed their usage plans they asked for a new setup fee, which we weren’t willing to pay. I’ve been requesting that they refund our forward payment for months now, and they simply ignore us. I really don’t recommend doing business with those guys.

Buffer