Slow web page loading is a very common problem and can sometimes be difficult to deal with. Fortunately though, there are tools like mod_pagespeed that can help you solve it.
What is mod_pagespeed
Mod_pagespeed is an open source add-on developed by Google, for Apache and Nginx web servers, created with the purpose of optimizing the performance of websites and the structure of its resources.
Through some filters present in this module you can automate some operations aimed at improving the resources on your site, reducing latency.
How it improves performance
Having an optimized and fast website brings several benefits, including greater visitor engagement. Mod_pagespeed brings several improvements to your site and, among its many features, allows you to:
- Compress and convert images into lighter formats.
- Reduce the size of HTML files, scripts, style sheets.
- Optimize the loading of resources, giving priority to the most important resources.
- Optimize the code and structure of the resources on the site, following Google’s guidelines.
How to enable mod_pagespeed from cPanel
By default it is not active on our systems, however you can enable mod_pagespeed by editing the .htaccess file present on your website.
To edit the .htaccess file, first login to cPanel.
From the main cPanel screen, scroll down the page to the “Files” section and select “File Manager“.
Locate the .htaccess file, right click on the file and select “Edit” from the context menu.
A confirmation message will appear, hit “Edit” again to begin editing the file.
Enter the following code inside the .htaccess file and save the changes you just made.
<IfModule pagespeed_module> ModPagespeed on </IfModule>
If you don’t see the .htaccess file in the File Manager panel, make sure the “Show hidden files” option is enabled in the settings.
If you want to completely disable mod_pagespeed from your site, enter the following code.
<IfModule pagespeed_module> ModPagespeed off </IfModule>
Properly configuring mod_pagespeed can greatly improve the performance of your website. The .htaccess file can be configured by enabling or disabling new options within it.
Enabling a mod_pagespeed filter
You can add new instructions by editing the .htaccess file, use this syntax:
To see the full list of filters, you can consult the official documentation on configuration filters.
Disable a mod_pagespeed filter
If you want to disable one or more filters, the use to follow is: