Page Speed Optimization

From DreamHost
Jump to: navigation, search
Dh-kb-important-icon.fw.png Important: As of September 15, 2015, Page Speed Optimization has been removed from the DreamHost Panel. It remains available for use (through a VPS or Dedicated plan), but is no longer supported by DreamHost.



Overview

Page Speed Optimization is a feature that reduces website loading times by automatically optimizing web pages and the resources within them. Under the hood of this feature is an Apache module that Google developed called mod_pagespeed.

FAQs

How does it work?

Page Speed Optimization dynamically adjusts the filenames of site resources, adding information about how 'old' the item is. It uses these age calculations to instruct visitor'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 visitor can use a cached version of a resource instead of requesting a new copy, there is no need for the visitor to wait for the request to be sent to the server and then wait for the server to send the resource back to their browser.
  • 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 if it's working?

Once you have manually installed Page Speed Optimization, go to your website and browse around a bit. Resources that are on multiple web pages, such as a header graphic, 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 web server. All the extra stuff (.pagespeed.ce.9-w9vHbyfP.gif) is added by Page Speed Optimization.

What if my page images get rewritten?

If an image with a name like "Åsen.jpg" gets rewritten by Page Speed Optimization (note the special character), try renaming it to "Aasen.jpg".

How long does it take for my edits to update?

If you've made edits to your site when Page Speed Optimization is active, you may not see these updates until 5 to 10 minutes later. DreamHost recommends that you disable this feature when updating a live site. This way your changes appear immediately. Once complete, you can then re-enable.

How can I clear the PageSpeed cache?

If you have a Dedicated Server, and you are an admin user, you can run:

sudo touch /var/mod_pagespeed/cache.flush

Customizations

Page Speed Optimization has a lot of additional filters which you can use to minify even further by means of custom code in an .htaccess file. You can read more about these filters on Google's site here:

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>

Below is further information about the filters used in the above example:

remove_comments
removes 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 optimizes images (med. risk)
elide_attributes
removes 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