How To Set Up Google PageSpeed Service With WordPress

Recently Andrew over at We Build Your Blog let me know that Google’s PageSpeed Service was now available for website owners to use.

What is Google PageSpeed Service?

It’s a service that essentially takes your website, optimizes it for speed and then serves it back to readers seamlessley. This video explains more:

How do I get it?

At the time of writing it’s invite only, but invites appear very quickly after applying.

1) Go over to https://developers.google.com/speed/pagespeed/service and sign up.

2) Once approved you will get an email with your access link.

3) Click on Add New Domain and the box will expand

google-pagespeed2

4) Enter your URL in there and press add. Note that the URL needs to have www. in it. If your site doesn’t use www in the URL you will need to change it to, see below for instructions.

5) You need to make a CNAME change in your domain. Usually this is in your web host. So if your webhost has cPanel, login and go to Advanced DNS Zone Editor (in the domain section). Select your domain from the dropdown and once the Zone File Records section opens find the row that looks like

www.domain-name.com. 14400 IN CNAME domain-name.com

where domain-name is your website domain name. Click the Edit to the right and change the Record to be pagespeed.googlehosted.com instead. So the record now looks like:

www.domain-name.com. 14400 IN CNAME pagespeed.googlehosted.com

Messing this up can break your site, but if you get any errors with your website just change it back to the domain name and your site will work again.

6) That’s it! Check your site is still working. Then back in your PageSpeed Service Overview (where you added the domain in step 3) you can run a speed test and it will show you how much time has been taken off your loading time.

The below is only needed if your site doesn’t have www in it.

google-pagespeed1

Changing your site to use www

There are three steps in WordPress to adding in www to your URL if you don’t have it.

1) In WordPress itself go to Settings > General and add in www.

2) In your .htaccess file in the root folder of your website, add in the following. Please, please make a backup of .htaccess first as any wrong move can break your site.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain-name\.com
RewriteRule (.*) http://www.domain-name\.com/$1 [R=301,L]

where domain-name is replaced with the actual name of your site. All this is doing is redirecting non-www URLs to www ones.

3) In Google Webmaster Tools, in your domain go to Configuration > Settings and set the preferred domain to be www (see below):

google-webmasters

Then your site will use www and your search engine rankings will stay the same as with non-www. Once done you can use the Google PageSpeed Service.