Google PageSpeed Module (mod_pagespeed) for performance improvement

Here in this article, we are discussing Google PageSpeed Module, also known as mod_PageSpeed. It’s generally confused with Google PageSpeed Insights, but it’s a bit different. Google Pagespeed Insights is a performance measurement/insights tool, and the mod_PageSpeed module is an open source server-level package that helps optimize website performance.

It’s not WordPress plugin; it is installed at the server level. It’s not WordPress specific either; as it works at the server level, it can be used for any website. As of 2021, mod_PageSpeed is available for Apache and Nginx.

What mod_PageSpeed does?

In Google words, it’s “the filters improve performance for JavaScript, HTML, and CSS, as well as JPEG and PNG images, “ i.e., it:

  • Caches files
  • Minifies CSS, JS, HTML
  • Combines JavaScripts
  • Prioritize important CSS and defer JS
  • Optimizes images (PNG to JPEG, Image resizing, WebP conversion), etc

Check if mod_PageSpeed is enabled

A lot of servers comes with mod_pagespeed enabled; to check it, use the following command on Apache

  • Open opt/bitnami/apache2/conf/httpd.conf and looking for the following lines
Include conf/pagespeed.conf
Include conf/pagespeed_libraries.conf
  • module will be located at /opt/bitnami/apache2/modules/

How to Install mod_PageSpeed on Debian/Ubuntu?

sudo dpkg -i mod-pagespeed-*.deb
sudo apt-get -f install

This installs

  • two version of mod_pagespeed, for Apache 2.2 and for Apache 2.4.
  • pagespeed.conf, pagespeed_libraries.conf – If you update these configuration files, it will stop the automatic package upgrade.

How to upgrade PageSpeed Module?

sudo apt-get update
sudo apt-get upgrade
sudo /etc/init.d/apache2 restart

How to set and check PageSpeed Statistics?

  • Go to browser
  • for security purposes, PageSpeed is accessible only when using as the hostname.

Flush Cache

sudo touch /opt/bitnami/apache2/var/cache/mod_pagespeed/cache.flush
sudo /opt/bitnami/ restart apache

Disable PageSpeed

  • Open opt/bitnami/apache2/conf/httpd.conf file and comment out following lines
#Include conf/pagespeed.conf
#Include conf/pagespeed_libraries.conf
  • Restart Apache
sudo /opt/bitnami/ restart apache

Note that mod_PageSpeed is not a magic bullet; you need to install and monitor it.

About Author

Sorry, Comments are closed!