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?".

FAQ

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.

Troubleshooting

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 unless you disable and enable it. This is (in part) due to how Google initially designed PageSpeed, and requires some serious refactoring for anyone to do otherwise.

Customizations

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

https://developers.google.com/speed/pagespeed/module/filters

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
</IfModule>
  • 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)

See also