Skip to content

PageSpeed

Warning

We no longer recommend using PageSpeed. The module has not been maintained for some time now, and as such, it may cause stability issues.

The PageSpeed module allows OpenLiteSpeed to support Google's PageSpeed optimization system.

For this guide, we assume you already have a working installation of OpenLiteSpeed 1.4.2 or greater. The PageSpeed module is not added to OpenLiteSpeed installations automatically and must be built or installed through rpm/deb packages.

Note

Linux is the only OS to support PageSpeed Optimization Libraries (PSOL) and thus OpenLiteSpeed only makes a PageSpeed Module for Linux.

Installing the PageSpeed Module

You can install the LiteSpeed PageSpeed Module when you install OpenLiteSpeed through the LiteSpeed repo. Or, if you prefer to build OLS from source, you can build the PageSpeed module from source, too. We've explained both methods below.

Install from the LiteSpeed Repo

Enable the LiteSpeed repository:

sudo wget -O - https://repo.litespeed.sh | sudo bash

Run the following command:

yum install ols-pagespeed
apt-get install ols-pagespeed

This rpm will install modpagespeed.so to /usr/local/lsws/modules/.

Build from source

Download and install OpenLiteSpeed 1.4.2 or higher if you have not done so already.

There are three steps to building the module:

  1. Add the PageSpeed optimization libraries (these are a set of C++ classes that automatically optimize web pages.)
  2. Build the modpagespeed.so dynamic library
  3. Move the dynamic library to the modules directory

Run the following commands to complete these steps:

cd /openlitespeed_download/src/modules/pagespeed
./dlpsol.sh
make
cp modpagespeed.so /usr/local/lsws/modules

Setting Up The PageSpeed Module

You have choices for how to set up the module:

  • You can set it up through the WebAdmin Console
  • You can append the configuration to the OLS main configuration file.
  • You can add include /usr/local/lsws/conf/modpagespeed.conf to the OLS main config file if modpagespeed.conf exists.

From the WebAdmin Console

Navigate to Server Configuration > Modules. Click the Add button.

  Enter modpagespeed as the Module name

Set parameters with google default filter sets. You can configure PageSpeed using a variety of settings and filters. The following are some default parameters:

pagespeed on
pagespeed FileCachePath /tmp/lshttpd/pagespeed
pagespeed RewriteLevel CoreFilters

Or you can use the configuration parameters covered in the modpagespeed.conf file located in /usr/local/lsws/conf, if it exists.

Save the module settings.

Restart the server.

From the configuration file

You can edit OpenliteSpeed's configuration file directly from the command line. Edit the httpd_config.conf file, and append the following content:

module modpagespeed {
param <<<END_param
pagespeed on
pagespeed InPlaceResourceOptimization off
pagespeed FetchHttps enable
pagespeed FileCachePath /tmp/lshttpd/pagespeed/
pagespeed EnableFilters remove_comments
pagespeed EnableFilters local_storage_cache
pagespeed EnableFilters extend_cache_pdfs
pagespeed EnableFilters combine_css
pagespeed EnableFilters rewrite_css
pagespeed EnableFilters extend_cache,rewrite_images
pagespeed EnableFilters rewrite_javascript
#pagespeed FileCacheSizeKb 102400
#pagespeed FileCacheCleanIntervalMs 3600000
#pagespeed FileCacheInodeLimit 500000000
pagespeed FetcherTimeoutMs 5000
#pagespeed ModifyCachingHeaders off
#pagespeed MapProxyDomain http://127.0.0.1:8088/ http://ref.pssdemos.com/
#pagespeed RunExperiment on
#pagespeed EnableFilters inline_images
#pagespeed LoadFromFile https://127.0.0.1:7080 /usr/lsws/lsws/admin/html/
#pagespeed LoadFromFile https://127.0.0.1:8088 /usr/local/lsws/Example/html/
END_param
}

Through an include file

Instead of appending all configurations directly to httpd_config.conf, you may use an include file.

Create modpagespeed.conf, if it doesn't exist, and add the above content to it.

Edit httpd_config.conf, and add the following line:

include /usr/local/lsws/conf/modpagespeed.conf 

Configuration

You can configure OpenLiteSpeed's PageSpeed Module using the same syntax as outlined in Google's documentation for the NGINX module.

Important Parameters

  • pagespeed on/pagespeed off: This parameter turns PageSpeed on or off at the server or virtual host level.
  • pagespeed FileCachePath: Determines the location of the PageSpeed cache. (If this directory does not exist, OpenLiteSpeed will create it.)
  • pagespeed RewriteLevel CoreFilters: The Google PageSpeed team believes the dynamically-updated CoreFilters set is safe for most websites.

Further configure the module at the virtual host level

You can further configure the PageSpeed Module at the virtual host level. (Google does not support context- and script handler-level configurations.) Also, virtual host-level configurations will always override server level-configurations.

Warning

Always leave the Enable Hooks setting as Not Set. Setting it to No will not disable PageSpeed at the virtual host level and may cause unpredictable functionality. To disable PageSpeed at the virtual host level, use pagespeed off in the virtual host-level module parameters.