Using PageSpeed with

Because is the only CDN that offers you the choice of reverse proxy, you can choose to bring the PageSpeed Module created by Google into your reverse proxy chain. PageSpeed was created by Google to improve your website’s performance by rewriting web pages and optimizing static assets. You can accomplish many things with PageSpeed like: optimizing images, minifying JavaScript and CSS files, defer JavaScript libraries, and much more. Below are the following steps you will need to take to get PageSpeed up and running within your reverse proxy chain.

Setting up PageSpeed in

To add PageSpeed to your reverse proxy chain, you must add it through the local CLI, by running the following command within the directory of your repository:

section append pagespeed:

After running this command, you will notice a pagespeed directory within your repo containing two files named http.conf and server.conf.

In the http.conf place any PageSpeed directives that need to be specified at the nginx “HTTP” level, and place all other directives withing the server.conf file.

Using PageSpeed alongside Varnish

PageSpeed has it’s own internal cache which causes problems when used alongside the Varnish reverse proxy. You will need to add a VCL file located here, to your varnish directory. You will then need to add the following code snippet above your vcl_recv block in your default.vcl file:

include "pagespeed-requirement.vcl";

Basic Config

Turning PageSpeed on and off

To turn PageSpeed on and off simply change line 1 in your default server.conf file located in your pagespeed directory on your application repository:

If you want PageSpeed turned on:

pagespeed On;

If you want PageSpeed turned off:

pagespeed Off;

Enable and disable filters

By default we have enabled only the specific filters listed in EnableFilters, not the PageSpeed CoreFilters on line 7 of the default server.conf file.

pagespeed RewriteLevel PassThrough;

This link here provides a list of filters available with PageSpeed’s EnableFilters. To enable or disable any of the filters just append or remove the filter name from line 10 of the default server.conf file.

pagespeed EnableFilters "add_head,combine_css,combine_javascript,convert_meta_tags,extend_cache,fallback_rewrite_css_urls,flatten_css_imports,inline_css,inline_import_to_link,inline_javascript,rewrite_css,rewrite_images,rewrite_javascript,rewrite_style_attributes_with_url";

Advanced Config

To learn how to configure PageSpeed, please check out the PageSpeed config documentation.

Below are a list of all the PageSpeed filters with links to instructions on how to properly implement them within your server.conf file. You will be following the nginx configuration instructions as PageSpeed is configured with nginx on