Speed up Magento with Rackspace Cloud Files Content Distribution Network
Using a content distribution network (CDN) to serve the images for your Magento site is a great cost effective way to improve your page load times. The benefits are two fold in that the user loads the image files from a super fast content delivery network like Rackspace’s cloud files to give them a faster download time of the image files and by alleviating your web server of this load it has more resources free for rendering the page.
Thanks to some great work by one pica there is a free to use Magento module that takes most of the hassle (it does need a tweak for Rackspace UK) out of setting this up.
First step is to sign up for a cloud files account with Rackspace UK, you don’t get charged for anything until you actually start using the service and even then it is as little as 11pence per gigabyte.
Install the OnePica Image CDN module via magento connect (backup your store before installing any module).
Once the module is installed you then have to configure this and to do so you will need a few details from your Rackspace account. Once logged in to your Rackspace account select Cloud Files from the menu under hosting, (if this is your first time logging in you will be prompted to generate an API key take note of it you will need it shortly). On the cloud files screen (below) you need to create a new container to be used by your Magento installation using the “add container” button.
You need to create a container for your Magento site to store files in.
You need to create a container for your Magento site to store files in.
Once you have created your container then click on it to select it and the bottom area will display the CDN & Metadata for this container. Tick the box marked “Publish to CDN” and a CDN URL will be generated for you in the box above.
Publish to CDN to get your CDN URL
Publish to CDN to get your CDN URL
The next step is to use the credentials you have just generated to configure your Magento store. Within the Magento admin the CDN module will have created a new configuration section under general called “Image CDN” within this you need to enter the API key, username and container details from your Rackspace Cloud files account (API Key can be found under “Your Account > API Access”).
To enable the CDN you then need to select Rackspace from “Current Adapater” drop down and hit save. Now if you are doing this in the UK you may see this error message.
The API credentials you provided for Rackspace Cloud Files were denied. You must enter new credentials to use Rackspace Cloud Files with this site.
The API credentials you provided for Rackspace Cloud Files were denied. You must enter new credentials to use Rackspace Cloud Files with this site.
This is because by default the moduel is set up to use Rackspace’s US API and the URL for UK accounts is slightly different. This can be easily fixed however by editing /app/code/community/OnePica/ImageCdn/Model/Adapter/Rackspace/cloudfiles_http.php and amending line 199 like so.
// non working US url //$path[] = "https://auth.api.rackspacecloud.com" // working UK url $path[] = "https://lon.auth.api.rackspacecloud.com"
Once you have made this change try saving the Image CDN settings again and this time the Cloud Files CDN should be activated. Reload a product or category page on the front end of your site and you should see the results as your images are served from Rackspace. At first the page load will be a little slower as the first time the images are viewed they have to be uploaded to the CDN, but each view after that should then be quicker.



