We’ve already seen how to configure and use the mod_pagespeed module in SiteGround. However, this is a heavily customized version of mod_pagespeed that doesn’t always work as expected. For one, the version currently in use is a couple of stages behind the most recent stable version. Of course, this is a shared hosting environment we’re talking about so there’s no chance of you being able to install your own server modules. But what if you’d like to use all the features of mod_pagespeed without having to rely on your web hosting provider to enable its full functionality? “What if we had a kind of reverse proxy” which intercepted web requests on your behalf and served up optimized pages instead?
A new Google service called Google PageSpeed is currently in testing and I was lucky enough to be able to obtain a sign up account. Since it’s not released to the general public, it’s free for me to use at the moment but from what I can see, it’s pretty cool and is a one-stop shop for all site optimization practices including CDNs. I can see this becoming a huge deal if it actually takes root and will provide serious competition to existing CDN practices. Let’s see how to set it up, how it works, and the effect it has on page load metrics.
Setting up DNS Servers
The Google PageSpeed service acts as a reverse proxy for your website. Much like a CDN, it intercepts requests to your URL and after having processed the source HTML, serves it back to the client. This has all sorts of interesting applications such as being able to serve resources from locations closest to the origin request – again, just like a CDN. While many CDNs leave it up to you to redirect requests for static resources to the servers, Google PageSpeed simply asks you to change your DNS records instead.
We start off by adding a new domain once logged into the Google PageSpeed service. I’m going to use my own site as a test dummy since I already have historical speed data making it easy for me to compare before and after results.
Once you’ve added your domain to Google PageSpeed, you’ll see a “Not Setup” message in red. When you click it, there instructions asking you to change your DNS CNAME records as shown here:
This is quite a simple operation. Log into your cPanel account (in this case, SiteGround), and choose the “Advanced DNS Zone Editor”:
Locate the record containing the CNAME tag along with the domain name of your website. Make sure you don’t accidentally change another subdomain instead!
Click “Edit”, and in the place of the CNAME field type in “pagespeed.googlehosted.com” – the value given to you in the early a screenshot after setting up your domain:
Once done, save your DNS entry, sit back, and wait for the changes to propagate.
As soon as the Google PageSpeed service is aware of your DNS changes, the status of your site will be changed to “Enabled”:
Immediately, you will begin to see a dramatic improvement in your site’s loading time as Google PageSpeed performs all kinds of optimizations to your source material without actually touching any code on your origin server. You can get an idea of the impact by clicking “Run speed test” which will take you to a website speed testing service with a side-by-side comparison of before and after effects:
Using only the basic Google PageSpeed optimizations, we were able to obtain a 30% decrease in the page load time. The results are even more impressive when you consider the impact on other metrics such as document interactive time (which is a much more visual indicator of your visitors experience).
Thanks to optimizations such as inlining critical CSS, and rearranging the loading order, I was able to obtain quite incredible results when measuring the document interactive time as shown here in Google Analytics:
I’m not sure when the Google PageSpeed service will be ready for public access, nor what their pricing scheme will be. I can say however that its release will be a huge shakeup for the CDN industry which currently does not do much in the way of page optimization. It might even have an indirect impact on hosting services!