Google's mod_pagespeed for Apache 2.2+

Last updated on
16 August 2016

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

In November of 2010 Google released an Apache module named mod_pagespeed. This is a server side module for Apache designed to manage caching of a various optimizations which effect client side page loading.

Tasks such as optimizing images, css and javascript are performed on the server and cached.

Drupal, being a complex content management system, offers many similar optimizations. However, there are times when Drupal is not able to perform its own built in optimizations.

For example, when setting the file system setting to Private, Drupal will disable the ability to aggregate CSS and JavaScript under the Site configuration > Performance section. Google’s mod_pagespeed can still perform some of these optimizations.

More extensive information can be found at Google’s mod_pagespeed docs page

Usage warning: This Apache module is a beta release and should be tested thoroughly before using on a production site. As of this writing, it seems that most all default filters within mod_pagespeed will work with the exception of Add Head and Minify JavaScript. More testing will be needed by the Drupal community.

To disable the above mentioned filters you would enable this configuration line within the pagespeed.conf file. See Configuring PageSpeed Filters if you need to disable more filters.

Broken filters that should be disabled:

  • rewrite_css may destroys one CSS file and then combines the destroyed file with the others. Your site will go down than. It may be an IE-hacks inside it is not safe for rewrite and this causes a fail, but the real root cause is currently unkown. You may see binary data inside the rewritten CSS file if this happens. As Drupal has CSS rewriting build in it is strongly recommended to disable this buggy filter.
  • inline_javascript filter destroys normal <script src="foo.js"></script> tags added to page footer region. Same like CSS, you will see some binary code.
  • inline_css (untested) should be like inline_javascript. It is untested, but better safe than sorry.
  • rewrite_javascript seems to cause some other strange issues. If you run Speedy module all core JS is already minified. Many other modules also provide minified versions. For the rest, better safe than sorry. By default the combine_javascript filter can be enabled to combine JS files as it may can do a better job than Drupal core already does.
<IfModule pagespeed_module>
# Disable broken and conflicting features.
ModPagespeedDisableFilters add_head,rewrite_css,inline_css,rewrite_javascript,inline_javascript
</IfModule>

To disable the entire mod_pagespeed module e.g. if your hoster has enabled it by default and you'd like to get rid of it:

<IfModule pagespeed_module>
# Turning the mod_pagespeed module off
ModPagespeed off
</IfModule>

In summary the mod_pagespeed seems to cause more negative and unpredictable side effects than any positive. Many of the issues are intermittent. If you do not like to risk your site going down you should better keep it disabled.

Help improve this page

Page status: No known problems

You can: