Writing/Reading Yii Assets on CDN

I searched for “CDN”, but didn’t find any similar threads.

Basically we use Yii’s Asset manager for everything and love how its generated dynamically. However, what if we wanted to push these assets files to a CDN cloud storage, such as amazon s3 or rackspace cloudfiles?

This is to eliminate static http requests (css,js,images) from our apache web server.

Is there a suggested best practice or ideas?

what is “CDN” ? :)

If you search google for "php s3" you will come up with quite a few hits (like this one: http://code.google.com/p/php-aws/ or http://undesigned.org.za/2007/10/22/amazon-s3-php-class ), which you can then write a simple wrapper for whichever one you like best.

I’ve not tried merging that into the asset manager, only used the S3 class for pushing to the CDN and creating buckets but I would think that it should be quite possible to come up with an alternate publishing method for the s3 option.

I don’t know if it will help get you in the right direction or not, but I just shared the Yii wrapper I build for the S3 class.

es3 Extension

Thanks for your replies. CDN = Content Delivery Network. It lets you store files on the cloud and is regionally located across various servers around the world, so its server up faster to your users. It also removes the load from your server.

Okay so I know how to upload files to S3 via php or any language, done it many times. The real question is, how do we go about getting YiiFramework AssetManager to handle this? I guess we would have to override AssetManager and change its storage mechanism.

Yes, I would extend it and add a publishCDN option.