There are many factors that can affect the speed of a website, and one of them is the server performance – how fast the server can render the web page and serve it to the browser. While there are many ways to improve the speed of a WordPress site, there are also server tools that can optimize the performance of a server. PageSpeed Module for Apache is one of them.
The PageSpeed module is a module for the Apache web server to optimise web pages, improve performance and apply output filters.
Some of the main features of the PageSpeed module include decreasing load time, the amount of requests and payload size. You can use up to 44 filters to optimize your webpage. Here is what the PageSpeed Module can do:
The above is minified to make this:
The above two files both do the same job, but the second one is smaller in size, hence translates to a fast load time of the site.
- The Pagespeed module comes with a number of rules that it uses to compress and optimize images to reduce the website’s load time. The rules include responsive images, lazyload images and Inline preview which shows a low quality of images.
The following commands install the PageSpeed module in Ubuntu. Do note that this is for Apache, which mean your server need to be running Apache. If you are using Nginx, you have to build from source.
If you are using a 32-bit OS, run this command:
Run this command for a 64-bit OS:
The above commands download the package. These commands unpack and install it.
sudo dpkg -i mod-pagespeed-*.deb sudo apt-get -f install
Installing PageSpeed adds Google’s repository to the system, so it will auto-update itself on every system update. We can verify the installation by running the command below and you will get the output shown:
curl -D- 22.214.171.124 | head
The configuration file is stored at the “/etc/apache2/mods-available/” directory. When installing PageSpeed, the module is automatically enabled as well as the “mod_deflate” which is a module for gzip compression.
To turn the PageSpeed module on and off, edit the configuration file using your favorite text editor.
sudo nano /etc/apache2/mod-available/pagespeed.conf
Opening the file, you can see that “ModPagespeed” is set to “on” by default. Changing this to “off” will disable the Pagespeed module.
While PageSpeed is optimizing a website, it generates some resources that are stored in a directory called “pagespeed_static”. To change this directory, edit the configuration file and add this line:
The PageSpeed module gives a browser interface to view the statistics of its output. To access the browser interface on a public IP, you will need to edit the following lines in the configuration file:
Below the Allow from 127.0.0.1 line, add a similar line with your public address in place of the localhost address, something like:
Allow from 192.xx.xx.xx
Replace “192.xx.xx.xx” with your public IP address.
You can now restart Apache and visit that address. You will see an output that looks similar to this;
The PageSpeed Module provides a good way for a webmaster to optimize the server performance without having to do a lot of tweaking. It can be easily installed and work out of the box. A little note though, when enabling its filters, it is best to test it on a test server and see if it works first before making it live.