mod_pagespeed is an open-source Apache module that automatically optimises web pages and resources on them. It does this by rewriting the resources using filters that implement web performance best practices. Web masters and web developers can use mod_pagespeed to improve the performance of their web pages when serving content with the Apache HTTP Server.
To install the packages, on Debian/Ubuntu, please run (as root) the following command:
dpkg -i mod-pagespeed-*.deb
apt-get -f install
Installing mod_pagespeed will add the Google repository so your system will automatically keep mod_pagespeed up to date.
After installing mod_pagespeed, it can be customized and configured by editing the Apache configuration file /etc/apache2/mods-enabled/pagespeed.conf
Open the mod_pagespeed configuration file using command:
sudo nano /etc/apache2/mods-available/pagespeed.conf
Below is my configuration setting, just paste this and restart apache server and you’re good to go.
mod_pagespeed required a disk cache that must be configured to a directory to which httpd has write access. The default configuration file sets this to /var/mod_pagespeed/cache/. To put the cache elsewhere please edit ModPagespeedFileCachePath to the desired location. A quick glance at the Apache error log file, typically in /var/log/apache2/error.log, will indicate whether the current setting is working.
After editing the conf file, you must restart the httpd server:
sudo /etc/init.d/apache2ctl restart
Turning OFF mod_pagespeed
To turn off mod_pagespeed completely, insert as the top line of pagespeed.conf and restart your apache server:
Turning ON mod_pagespeed
To turn mod_pagespeed ON, insert as the top line of pagespeed.conf and restart your apache server:
There are many more mod_pagespeed configuration you can do, please do check this out for more details.
You can also download a number of system tests to check the improvement in performance.