Skip to content

Instantly share code, notes, and snippets.

@waskito
Forked from smj10j/pagespeed.conf
Created May 24, 2017 16:56
Show Gist options
  • Save waskito/59145d658bd6c79dc136375ea5467e28 to your computer and use it in GitHub Desktop.
Save waskito/59145d658bd6c79dc136375ea5467e28 to your computer and use it in GitHub Desktop.
Nginx conf for mod pagespeed
# Google Pagespeed
# https://developers.google.com/speed/pagespeed/module/configuration
pagespeed on;
pagespeed FileCachePath /var/cache/ngx_pagespeed/;
# let's speed up PageSpeed by storing it in the super duper fast memcached
pagespeed MemcachedThreads 1;
pagespeed MemcachedServers "127.0.0.1:11211";
# show half the users an optimized site, half the regular site
pagespeed RunExperiment on;
pagespeed AnalyticsID UA-33398334-1;
pagespeed ExperimentVariable 1;
pagespeed ExperimentSpec "id=1;percent=50;level=CoreFilters;enabled=collapse_whitespace,remove_comments;";
pagespeed ExperimentSpec "id=2;percent=50";
# PageSpeed Cache Purge
pagespeed EnableCachePurge on;
pagespeed PurgeMethod PURGE;
# Filter settings
pagespeed RewriteLevel PassThrough;
# 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;
# 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$" { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment