Page Speed Optimization

From DreamHost
Jump to: navigation, search
Page speed opt screenshot.jpg
Page Speed Optimization is a tool that reduces website loading times by automatically optimizing web pages and resources on them. It is an apache module, mod_pagespeed, from Google. It was announced in DreamHost's blog in 2010.

You can turn it on and off from the panel's Manage Domains section. Find the domain, click the Edit button, and in the Fully Hosted section of the page check the box for "Page Speed Optimization?".


How does it work?

The mod_pagespeed apache module dynamically adjusts the filenames of site resources, adding information about how 'old' the item is. It uses these age calculations to instruct user's browsers to serve cached copies of resources instead of requesting new copies. This cuts down on the number of requests to the server, which improves site speed in two ways:

  • when a user can use a cached version of a resource instead of requesting a new copy, there is no need for the user to wait for the request to be sent to the server and then wait for the server to send the resource back to the user
  • with the server serving less resource requests, it has more resources to jump on the requests it does receive, so those requests can potentially be filled in less time

How can I tell it's working?

Go to your website and browse around a bit. Resources that are on multiple web pages, such as a header graphic, will have a filename like originalFileName.gif.pagespeed.ce.9-w9vHbyfP.gif. The originalFileName.gif is what you named it when you uploaded it to the webserver. All the extra stuff (.pagespeed.ce.9-w9vHbyfP.gif) is added by pagespeed.


If an image with a name like "Åsen.jpg" does get rewritten by pagespeed, try renaming it to "Aasen.jpg".

How can I clear the Pagespeed Cache

You can't on a shared web server, unless you disable and enable it for the domain.

If you have a VPS or dedicated server, your admin user can run:

sudo touch /var/mod_pagespeed/cache.flush


PageSpeed has a lot of additional filters which you can use to minify even further within .htaccess.

Here's an example:

<IfModule pagespeed_module>
    ModPagespeed on
    ModPagespeedEnableFilters remove_comments,rewrite_javascript,rewrite_css,rewrite_images
    ModPagespeedEnableFilters elide_attributes,defer_javascript,move_css_to_head
    ModPagespeedJpegRecompressionQuality -1
  • remove_comments – Remove HTML comments (low risk)
  • rewrite_javascript – minifies JS (med. to high risk, depending on your site)
  • rewrite_css – parses linked and inline CSS, rewrites the images found and minifies the CSS (med. risk)
  • rewrite_images – compresses and optomizes images (med. risk)
  • elide_attributes – removing attributes from tags (med. risk)
  • defer_javascript – combines JS and puts it at the end of your file (high risk AND experimental!)
  • move_css_to_head – combines CSS and moves it to the head of your file (low risk)

Other optimizations for speed

Both mod_pagespeed and other performance software (Zend Optimizer+, etc.) can be installed by GetPageSpeed service

See also