Wednesday, December 28, 2011

Is Google (and mod_pagespeed) the Poor Man's CDN?

EDIT: As per the comment by barryhunter below, this whole article is bogus. The CDN stuff was something I found under the 'Page Speed' heading but is related to Page Speed Service, as opposed to mod_pagespeed itself... Sorry for the confusion.


Since it was available as a browser plugin, I've been intrigued by the Page Speed concepts that Google have promoted. There was just something about the entire project that I loved... the fact that people out there are so passionate about these ideas that they were writing code to help me better understand the problems my site was having... it's a great project.

Then when the Page Speed module for Apache was released, I was blown away. Automating the work that can be done, basically 'earning' a lot of the benefits of the Page Speed knowledge, simply by installing an extension to Apache... again, just fantastic.

But to be honest, lately, I've been ignoring it. We installed it on our servers, appreciated the work that it was doing for us and then we moved on.

Just recently, though, when trying to explain the concepts to a workmate, I had reason to look back at the site and read through the documentation again. Now admittedly I have not had any need for a content distribution network until recently. In fact, if it wasn't for a friend of mine I still would have no need for it. So I don't know if it is my 'new found knowledge' of CDNs, new changes to mod_pagespeed or a combination of both, but looking back over the documentation I found something really cool: mod_pagespeed has some 'proxying' options that will proxy your images, JS and CSS!

Basically by enabling these options, mod_pagespeed will rewrite your HTML so that the CSS, JS and images are 'proxied' through the Google network. That is to say, instead of requesting http://www.example.com/my.css, the rewritten HTML will have the browser request something like http://3-www-accel-pss.googleusercontent.com/www.example.com/my.css. These servers appear to be a CDN: that is to say, the browser is sent to the nearest server.

And the best thing? It's free! For now, at least.

So that was my little 'excitement' for the day. If you can't afford to pay for a CDN and you have enough control over your server, do yourself a favour: install mod_pagespeed and turn on the proxying features.

4 comments:

  1. Are you sure these Proxy options are part of mod_pagespeed?

    They are not listed on the filter page
    http://code.google.com/speed/page-speed/docs/filters.html



    They are part of Page Speed Service
    http://code.google.com/speed/pss/
    which does pretty much bill itself as a optimised CDN. (although it doesnt mention the term "CDN" much)

    http://code.google.com/speed/pss/faq.html#howmuchdoesitcost
    "At this time, the service is being offered to a limited set of webmasters free of charge. Pricing will be competitive and details will be made available later. You will then have at least 30 days to decide if you want to continue using the service."

    ReplyDelete
    Replies
    1. Barry I think you're totally correct. I guess I got confused by the all of the links being under the 'Page Speed' heading.

      That sucks. I wonder, though, if it would be possible to somehow get mod_pagespeed to do that in the future (assuming you had set up the PSS)?

      Delete
    2. mod_pagespeed & Page Speed Service are both trying to achieve similar goals, but the deployments differ. mod_pagespeed is an open-source Apache plugin, optimizing the your site at the origin. PSS optimizes your site in the cloud & serves it from Google's servers. mod_pagespeed of course requires Apache, butt PSS can work with any origin server.

      You can use mod_pagespeed with any CDN. It supports automated resource-proxying via the ModPagespeedRewriteDomains directive. Check http://code.google.com/speed/page-speed/docs/domains.html . Also check out https://groups.google.com/forum/?fromgroups#!forum/mod-pagespeed-discuss where you'll find threads on this topic.

      If you use PSS you don't need to set that up.

      Hope this helps!
      -Josh

      Delete
    3. Thanks Josh: those links help. Apparently I need to do so more deep reading again!

      Delete