A CDN Hosted Blog
filed in Articles on Jul.03, 2010
So, with the event of Amazon’s Cloud Front and RackSpace Cloud’s Cloud Files (with the backing of Limelight Networks) the world and its mother can now use cheap and cherfull CDNs for hosting images, CSS and JS files for their blogs. but what about the rest of the blog?
In theory, a blog is 99% static. With the help of the likes of Disqus, you dont even need to manage your own comments. so, other than updates to the core template (which is probably not very often) and new blog posts (which for me is currently not very often), the rest of the site is very static. So, why cant that be hosted in a CDN? I am using a plugin on my Wordpress install called W3 Total Cache, and one of the options is to generate the HTML for a page, save it to disk, use a URL Rewrite to point to that HTML file for a certin amount of time, and, in theory, take some load of the server… the first time the page is generated, it should run though the PHP CGI engine (this site runs on IIS7 now) and then be built into a HTML page and passed to IIS to serve. the second time, its just served from IIS from disk, as a standard HTML page… and this got me thinking…
How hard would it be to take that outputted HTML page and upload to Amazon S3 or RackSpace CloudFiles? using the same HTTP Redirect, just serve it from the CDN and bobs your uncle? Now, me not being a PHP dev, the answer chould be “Very”… but the question then comes up of, why cant it not be done anywhere else? this is, to some extent, how the image hosting site I built works. i upload images to a SQL DB, which gives me a nice URL to use. I open the URL, and if the file has not be uploaded to the CDN, it uploads and redirects me to the CDN location. the next request just gets redirected to the CDN.
So, the next question: is it posible to build a Proxy system that will proxy requests to and from the IIS box. request comes in, if its already on the CDN, redirect to the CDN. If not, show the main site, and in the background push the page to the CDN. you would need to do some magic around Search Engines (since they might get confused with CDN links and your main page) and also around logged in users (especially if you are using WordPress). anyway, its a theory… throwing it out there. main reason i was thinking about it is the fact that my server is hosted in house on a Cable Modem… so ping times can be a little slow… as can response times… ideally, this should make visiting this blog a little faster… but also any blog hosted by it… or at least, thats the theory…
[Update] added some code on GitHub with a demo of a HTML Module. some work needs to be done, but will add it in over time…
July 3rd, 2010 on 1:30 pm
I've been using T3 on WordPress with CloudFront for a while now on a few sites. It's a really great combination. I think the effort of adding a proxy to serve your actual HTML files would not add much to performance, and you'd likely get into all sorts of problems with search engines and the like. Besides, HTML generally accounts for a small portion of the total payload of the page. You'd probably get better value by optimising the hell out of your client-side rendering.
Your site loaded plenty quick for me, so your home server isn't doing to bad a job at all
July 3rd, 2010 on 2:07 pm
Thanks for the comment Richard. A good chunk of my site is currently served on cloudfront… Thing is, even though its loading fast for you, thats only cause both of us are in ireland… Us load time can be slow… I do take your point about html being a small part, and mine is gzipped beford sending, but have started a demo project to see how it would work, as a proof of concept…
Sent from my Windows® phone.
July 3rd, 2010 on 2:11 pm
Very interested to hear how you get on with this.
July 3rd, 2010 on 2:19 pm
I will post updates here…
Thanks for your interest!
Sent from my Windows® phone.
July 22nd, 2010 on 2:01 am
Thats an interesting idea … But not sure how much time you would loose when doing all of the checking.
July 22nd, 2010 on 8:47 pm
If you can do the checking and cache the result, in theory it should
be quick…
Sent from my iPod
August 6th, 2010 on 7:27 am
[...] goes to the main page. and since you can use a CNAME to make the URL look like (like mine which is cdn.lotas-smartman.net) you can put your contents of your blog on CloudFront and build a fully hosted web site. no more [...]