If you’re using Apache and PHP 5.3 on your DreamHost domain, you have the magical power to enable Google PageSpeed. Just go and edit your domain and make sure you check the box for “Page Speed Optimization”:

PageSpeed Option

But what does that even mean, I hear you ask?

partnersPageSpeed is Google’s way to speed up the web (yeah, that was redundant), and it serves as a way for your server to do the work of caching and compressing, taking the load off your webapps. Like WordPress. Anyone can install this on their apache server, and it’s free from Google Developers: PageSpeed Mod. Since you’re on DreamHost, you lucky ducky you, we did it for you. Now you can sit back and relax.

The first thing to notice when you turn on PageSpeed is that it minifies your webpage. That means it takes your pretty formatted source code and gets rid of the extra spaces you don’t use. This is called by using the PageSpeed filter “collapse_whitespace.” Another filter we use is “insert_ga” which is how we’re magically able to insert your Google Analytics for you from your panel. That filter automatically inserts your GA code on every page on your domain. That’s right! No more plugins!

If you’re like me, you may start to wonder what other filters you should use, and that entirely depend on what you want to remove. I knew I wanted to remove code comments like the following:

<!-- #site-navigation -->

That’s easy! There’s a filter for “remove_comments” so I can just use that. They have a whole mess of filters listed in the Filter Documentation and reading through it took a while. If you read each one, at the bottom they talk about how risky a certain filter is. Taking that into account, I went ahead and added some low and some high risk filters, since I know what I’m using.

The magic sauce to add all this is just to edit your .htaccess and put in the following near the top:

<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

Really, that’s it.

The ones I picked are:

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

Now keep in mind, not all of the features will work. While DreamHost is on a pretty cutting edge version of PageSpeed, they’re constantly innovating over there and improving. The best thing about these changes is, if you do it right, you can speed your site up faster than any plugin could do for you. And that? Is pretty cool right there.

Reader Interactions


  1. Prayers and Apples says:

    Trying this right now – should I delete my Google Analytics plug-in that was previously installed? (And does that mean I should click “Google Analytics” under Web Options?) Also: will I still see benefits if all I do is check “Page Speed Optimization”? I’m afraid to mess with anything else since I don’t really know what I’m doing! And one more question: is there anyway this could mess up the format/how things look on my site – is there anything I should look out for?

    • Yes, click β€œGoogle Analytics” under Web Options when you turn on PageSpeed, and you can uninstall the plugins.

      You’ll still get benefits from just having pagespeed on, and the only issue I’ve see is when you’re making a lot of CSS/JS changes, and the cache hangs on to your previous files. When that happens, you can just turn pagespeed off and then back on, and it’ll flush the cache for you.

    • Prayers and Apples says:

      ok thanks! i followed your advice from the other forum post – i just changed my PHP settings to 5.3xFastCGI. I checked Pagespeed. I also installed WP Super Cache and clicked “Compress files so they’re served more quickly” and “Use PHP to serve cache files.” How long do you think it will take for me to notice a difference in page speed? Is there anything else I should do? And last question (thanks for your patience!): should I uninstall my Widget Cache plugin or will it just work with WP Super Cache?

    • It’s already working πŸ™‚

      If I view your source, I see this:

      The ‘pagespeed….’ in there tells me you’re good πŸ™‚

      According to GTMetrix, your site is darn fast! http://gtmetrix.com/reports/www.prayersandapples.com/VFouoCdZ

      I don’t know about Widget Cache, I’ve actually never used it, but you may not need WP Super Cache anymore. Hard to say without experimenting on your own site.

    • Prayers and Apples says:

      One more: do I have to sign up for Google Apps? I’m getting a message on my screen that’s saying it’s important that I do – but it’s not a free service. What happens if I don’t (and will this affect my page speed)?

    • You don’t need Google Apps. nothing will happen if you leave it alone πŸ™‚

  2. Prayers and Apples says:

    ok thanks so much! this is the best my site has ever run! you’re a computer genius πŸ™‚ thank you!! πŸ™‚

  3. This is just what i was looking for… i will try it after doing what i’m involved in now… πŸ™‚ great!

  4. I’m using PHP 5.2.xFastCGI, to change the PHP mode to PHP 5.3.xFastCGI(default) i just select it in dropdown menu? No harm will be done? And then I select Page Speed Optimization and that’s it, no?

    • And click ‘save’ yes πŸ™‚ No harm done. If you don’t like it, or it doesn’t work, you can click it back.

      I don’t know of anything that doesn’t work on 5.3 now, which is pretty solid in so far as PHP goes.

    • Ok, done! And what about what i have to write in the .htaccess? Should i put it in the root .htaccess of my site or in the wordpress folder .htaccess? In the root i suppose, no? πŸ™‚

    • I put it in my root, since I want to to affect everything on that site πŸ™‚ If I only wanted it to affect one thing on a site (like say a gallery or a wiki) then I’d do a folder htaccess.

    • great thanks!

  5. # BEGIN WordPress
    &lt;IfModule pagespeed_module&gt;
        ModPagespeed on
        ModPagespeedEnableFilters remove_comments,rewrite_javascript,rewrite_css,rewrite_images
        ModPagespeedEnableFilters elide_attributes,defer_javascript,move_css_to_head
        ModPagespeedJpegRecompressionQuality -1
    &lt;IfModule mod_rewrite.c&gt;
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # END WordPress

    Sorry i tried to post it properly but i don’t know how to…

    • Don’t worry πŸ™‚ You can just use the HTML code tags most of the time.

      Yes, that’s the right way to do it. I actually tend to put it outside of WP, so i have this:

      # Begin PageSpeed

      ModPagespeed on

      # END PageSpeed

      # BEGIN WordPress
      # END WordPress

      It just helps me later on when I’m trying to add new things πŸ™‚

    • great, much better! thanks!

  6. IT works so good! I will have an eye on this for the next weeks to see how it works, but for the moment is a great solution, thanks!

  7. Hi, just wanted to say that i checked my site with PageSpeed Insights Analyzing Tool and i did somemore changes to get more speed, like this one on the .htaccess file:

    # WEEK
    Header set Cache-Control “max-age=604800, public”
    # WEEK
    Header set Cache-Control “max-age=86400”

    Also i checked this post to minimize wordpress queries in the theme… site is so fast now!! thanks a lot!

    • Yes, Browser Caching settings like that are also amazing, but they’re a topic in and of themselves πŸ˜‰

  8. And what about Cloudfare, do you think is a good idea to activate both of them? thanks!

    • You know… I have never used CloudFlare or any other CDN. I understand what they’re for, but I can’t really see the benefit unless I was running a massive photo heavy site.

    • I sent a ticket to dreamhost about this to see what they tell to me πŸ™‚ i’ll tell you whatever it is…

  9. Do you know if this is enabled by default these days? Dreamhost placed 2/10 in my last batch of page speed tests, which is pretty impressive. Maybe they have this feature on for everyone now.

  10. Abhishek Jain, DarkUFO: No, blogger does not cunrertly implement mod_pagespeed, and because it is a hosted service there is no way to enable this functionality from the client.Sunita Kumari: mod_pagespeed can be used with any website that is served by an Apache HTTP server! Check the documentation and instructions by following the link in the blog post.

%d bloggers like this: