PageSpeed Module

< Back

 

This wiki discusses how to add and configure OpenLiteSpeed’s PageSpeed module. 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. Module support was made available in version 1.3 but the PageSpeed module is only available and supported as of version 1.4.2. The PageSpeed module is not added to OpenLiteSpeed installations automatically and must be built or installed through rpm/deb packages (OpenLiteSpeed 1.4.13 or greater).

Note: PageSpeed Optimization Libraries (PSOL) are only available for Linux and thus OpenLiteSpeed’s PageSpeed Module is only available for Linux.

Installing The LiteSpeed PageSpeed Module

Install The LiteSpeed PageSpeed Module Through RPM/DEB Packages

With Redhat/CentOS/Debian/Ubuntu,  PageSpeed mode has been included in the latest rpm/deb packages and you can install openlitespeed through LiteSpeed repos.

Enable the LiteSpeed repository(refer to LiteSpeed wiki) and run the following command:

Redhat/CentOS:     yum install openlitespeed
  
 Debian/Ubuntu:     apt-get install openlitespeed

This rpm will install modpagespeed.so to /usr/local/lsws/modules/ and  a sample PageSpeed config file, “modpagespeed.conf”, to /usr/local/lsws/conf/.

Setting Up The PageSpeed Module

You have choices for how to set up the module, either through webadmin console, or append configuration to OLS main conf , or use “include /usr/local/lsws/conf/modpagespeed.conf” in the OLS main conf file if modpagespeed.conf exists.

Setting up the module from WebAdmin Console

Add the PageSpeed Module by going to WebAdmin Console > Server Configuration > Modules > Add

Enter modpagespeed as the module name

 

Set parameters with google default filter sets. PageSpeed may be configured 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(if existing) located in /usr/local/lsws/conf.

Save the module settings.

Restart the server.

Setting up module from httpd_config.conf directly

Instead of adding the PageSpeed module from the WebAdmin Console, you can also edit OpenliteSpeed’s conf file directly from the command line and append the following content to httpd_config.conf. The content may be included in the optional modpagespeed.conf file(if existing).

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
}

Setting up module from httpd_config.conf through “include”

Instead of appending all configurations directly to httpd_config.conf, you may use “include” in the httpd_config.conf

If the above modpagespeed.conf exists, you can add the following line to httpd_config.conf:

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

Configuration

Configuration of OpenLiteSpeed’s PageSpeed Module follows the syntax 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: CoreFilters is a set of filters that the Google PageSpeed team believes are safe for most websites. The CoreFilters set is dynamically updated.

Further configure the module at the virtual host level

The PageSpeed Module can be further configured at the virtual host level. (Google does not support context- and script handler-level configurations.) Virtual host-level configurations will always override server level-configurations.

Note: 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.

 

Build The LiteSpeed PageSpeed Module if you install openlitespeed from source

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

The PageSpeed Module is available as of OpenLiteSpeed version 1.4.2.

Add PageSpeed Optimization Libraries

The PageSpeed Optimization Libraries (PSOL) are a set of C++ classes that automatically optimize web pages.

Go into the PageSpeed Module directory /openlitespeed_download/src/modules/pagespeed and run ./dlpsol.sh (or ./ccc.sh for earlier PageSpeed versions) to get the latest version of PSOL supported by OpenLiteSpeed. Do not use other versions of PSOL as they may not be supported. (The currently supported version of PSOL can be found in our release log.)

cd /openlitespeed_download/src/modules/pagespeed
./dlpsol.sh

Build modpagespeed.so

make

Note: If compiling does not work, try gmake instead of make.

Move The Dynamic Library To The Modules Directory

cp modpagespeed.so /usr/local/lsws/modules