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?
- Caches files
- Minifies CSS, JS, HTML
- 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/mod_pagespeed_ap24.so.
How to Install mod_PageSpeed on Debian/Ubuntu?
sudo dpkg -i mod-pagespeed-*.deb sudo apt-get -f install
- two version of mod_pagespeed, mod_pagespeed.so for Apache 2.2 and mod_pagespeed_ap24.so 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 http://127.0.0.1/pagespeed_admin
- for security purposes, PageSpeed is accessible only when using 127.0.0.1 as the hostname.
sudo touch /opt/bitnami/apache2/var/cache/mod_pagespeed/cache.flush sudo /opt/bitnami/ctlscript.sh restart apache
- 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/ctlscript.sh restart apache
Note that mod_PageSpeed is not a magic bullet; you need to install and monitor it.