FeaturesWP CloudPricingEE CLIContactMy Account

Features

Team Access & User Permissions

Server Setup & Management

Site Creation & Management

Deployments & Developer Tools

Firewall Protection

Speed & Caching

Backups & Recovery

Logs & Monitoring

Create WP Cloud Sites

All Features

Read Documentation

Install

Installation Guide

FAQ

Roadmap

Explore EE CLI

Resources

Commands

Handbook

Blog

Community

Forum

EasyExperts

Tutorials

Subscribe

Github

CLEAR

Start For Free

separator Tutorials separator Nginx separator Using Pagespeed

Topics

On this page

Adding Nginx repo

Installation of Nginx Pagespeed

Creating Pagespeed global configuration

Creating site specific Pagespeed configuration

Enable Pagespeed for site

Enable/Disable PageSpeed Filters

Test your site

View Pagespeed statistics

Disable Pagespeed temporary

Purge Pagespeed Cache

Using Pagespeed

Note: This feature is depreciated with EasyEngine v3.6.0.

Note: Test your site properly before using this in production.

Adding Nginx repo

If you are EasyEngine user then you can skip this step

For Ubuntu 12.04/14.04:


			add-apt-repository -y ppa:rtcamp/nginx
apt-get update
		

For Debian 6/7:


			echo "deb http://packages.dotdeb.org $(lsb_release -sc) all" > /etc/apt/sources.list.d/dotdeb-$(lsb_release -sc).list
apt-get update
		

Installation of Nginx Pagespeed

For Ubuntu 12.04/14.04:


			apt-get install nginx-custom
		

Note: If you are using EasyEngine then this step is not required

For Debian 6/7:


			apt-get install nginx-extras
		

This will install nginx-extras on your server, by removing nginx-full.

Creating Pagespeed global configuration

Create new pagespeed global configuration file


			vim /etc/nginx/conf.d/pagespeed.conf
		

and paste following code into it


			# Turning the module on and off
pagespeed on;

# Configuring PageSpeed Filters
pagespeed RewriteLevel PassThrough;

# Needs to exist and be writable by nginx.  Use tmpfs for best performance.
pagespeed MemcachedServers "127.0.0.1:11211";
pagespeed FileCachePath /var/ngx_pagespeed_cache;

# PageSpeed Admin
pagespeed StatisticsPath /ngx_pagespeed_statistics;
pagespeed GlobalStatisticsPath /ngx_pagespeed_global_statistics;
pagespeed MessagesPath /ngx_pagespeed_message;
pagespeed ConsolePath /pagespeed_console;
pagespeed AdminPath /pagespeed_admin;
pagespeed GlobalAdminPath /pagespeed_global_admin;

# PageSpeed Cache Purge
pagespeed EnableCachePurge on;
pagespeed PurgeMethod PURGE;
		

Creating site specific Pagespeed configuration

Create new site specific configuration file


			vim /etc/nginx/common/pagespeed.conf
		

Paste following code into it


			# PageSpeed Admin
location /ngx_pagespeed_statistics { include common/acl.conf; }
location /ngx_pagespeed_global_statistics { include common/acl.conf; }
location /ngx_pagespeed_message { include common/acl.conf; }
location /pagespeed_console { include common/acl.conf; }
location ~ ^/pagespeed_admin { include common/acl.conf; }
location ~ ^/pagespeed_global_admin { include common/acl.conf; }

# Ensure requests for pagespeed optimized resources go to the pagespeed handler
# and no extraneous headers get set.
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
  add_header "" "";
}
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
		

 

Enable Pagespeed for site

Open site Nginx configuration:


			vim /etc/nginx/sites-available/example.com
		

add following line at in the configurations:


			include common/pagespeed.conf;
		

and restart Nginx


			nginx -t && service nginx restart
		

Enable/Disable PageSpeed Filters

 

Please paste following filter inside /etc/nginx/sites-available/example.com

 


			# HTTPS Support
# pagespeed FetchHttps enable;

# PageSpeed Filters
# CSS Minification
# pagespeed EnableFilters combine_css,rewrite_css;

# JS Minification
# pagespeed EnableFilters combine_javascript,rewrite_javascript;

# Images Optimization
#pagespeed EnableFilters lazyload_images;
#pagespeed EnableFilters rewrite_images;
#pagespeed EnableFilters convert_jpeg_to_progressive,convert_png_to_jpeg,convert_jpeg_to_webp,convert_to_webp_lossless;

# Remove comments from HTML 
#pagespeed EnableFilters remove_comments; 
# Remove WHITESPACE from HTML 
#pagespeed EnableFilters collapse_whitespace;

# CDN Support
#pagespeed MapRewriteDomain cdn.example.com www.example.com;
		

 

By default we commented all filters. You can uncomment filters that you need for your site.

Also you can add various filters from here to this file: https://developers.google.com/speed/pagespeed/module/filters

Test your site

You can test site by pointing browser to example.com, and seeing its html code.

View Pagespeed statistics

You can view Pagespeed statics by poinitng your browser to http://example.com/ngx_pagespeed_statistics

Disable Pagespeed temporary

You can disable pagespeed temporary by using this url: http://example.com/?PageSpeed=off

Purge Pagespeed Cache

You can purge specific file cache by hitting following url http://exmple.com/pagespeed_admin/cache?purge=/path/file.ext

 

Using $upstream_cache_status in access.log

PREVIOUS

Weak Diffie Hellman Logjam Attack Fix

NEXT


Features

Useful Links

Product

Other Products

Subscribe for curated product updates, tips, and announcements.

"*" indicates required fields

LinkedIn

This field is for validation purposes and should be left unchanged.

Email*

SIGN ME UP

Δ


© rtCamp, since 2009. All rights reserved.

Powered by