Using the Pagespeed Module

[Sorry, but the pagespeed module has been disabled due to performance issues. The module will be re-enabled once the issues have been fixed by Google.]

All hosting plans come with the Google “pagespeed” module that optimizes your website to make it faster for visitors.

Note: The pagespeed module is still labeled as “beta”, which means it is still actively worked on. There may be some minor bugs, and some features may change. In our experience, the module has worked without any problems and been very stable.

Activation

Enabling the “pagespeed” module for your site is very easy. Create a file called .htaccess in your html folder. (Note that the file begins with a period.) If the file already exists, just add to it.

Type or paste the following code:

<IfModule pagespeed_module>
ModPagespeed on
</IfModule>

That’s it! Save the file (and be sure to upload it to the server). If it’s working, then your site should look the same, but the HTML code will be slightly different. The module doesn’t actually change any of your files — all changes happen on the fly.

If your website stops working and you see “Internal Server Error” messages, then double-check the .htaccess file — there’s probably a typo. Contact our support team if you need help, or would like us to permanently enable pagespeed for your site.

Configuring Filters

You can fine-tune the optimizations (“filters”) that pagespeed uses. The safest optimizations are included in the default setup:

  • add_head – Adds a <head> element to the document if not already present
  • combine_css – Combines multiple CSS elements into one
  • extend_cache – Extends cache lifetime of all resources by signing URLs with content hash
  • inline_css – Replaces small images with data: URLs
  • inline_javascript – Inlines small JS files into the HTML document
  • rewrite_css – Rewrites CSS files to remove excess whitespace and comments, and rewritew or cache-extends images referenced in CSS files
  • rewrite_images – Optimizes images, re-encoding them, removing excess pixels, and inlining small images
  • rewrite_javascript – Rewrites JS files to remove excess whitespace and comments
  • trim_urls – Shortens URLs by making them relative to the base URL

Other filters can be enabled in your .htaccess file. For example, to add filters for removing comments and unnecessary quotation marks in HTML:

<IfModule pagespeed_module>
ModPagespeed on
ModPagespeedEnableFilters remove_comments,remove_quotes
</IfModule>

You can also remove filters by using ModPagespeedDisableFilters. For more information on configuring filters and the list of available filters, check out the pagespeed documentation.

Restricting URLs

You may wish to exclude some webpages or files from being optimized. For example, there is an issue where the TinyMCE editor (packaged with WordPress, Joomla, and other content management systems) stops working. To fix this, simply exclude it:

<IfModule pagespeed_module>
ModPagespeed on
ModPagespeedDisallow */tinymce/*
</IfModule>

(This is the fix for WordPress; the exact value will vary from site to site.)

You can read more about disallowing specific URLs in the official documentation.

Adding Domains

By default, Pagespeed will only optimize resources that originate from the same domain as the webpage. For example, given the webpage http://www.example.com/index.html, Pagespeed will only optimize resources that are part of www.example.com. If your pages embed images and other files from other subdomains (e.g., static.example.com) or websites (e.g., www.example.org), you can optimize those resources as well:

<IfModule pagespeed_module>
ModPagespeed on
ModPagespeedDomain http://static.example.com
ModPagespeedDomain http://www.example.org
</IfModule>

Warning: Only add domains that you own and control! Adding domains that aren’t yours (e.g., flickr.com) opens your website up to attack.

Need Help?

Post your questions in the comments below, or contact our support team for assistance.

Read More

Join the Discussion

  1. Technopsis says:

    Wow, that sounds really easy! Does it work for all servers?
    I made some changes for speed optimization recently myself and my page speed increased by more than 100%!
    If you use wordpress you can do this within 5 minutes! Read how I did it here: http://wp.me/p2jQY1-8j

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>