Steven Jones
A blog of electronics and programming

Mod Pagespeed

I've been playing with Mod Pagespeed at work quite a bit recently, we don't do Drupal hosting as such, but we set up infrastructure and make sure it's working for a number of our customers.

We've previously had to work in an envionrment where Mod Pagespeed was used very aggressively, and broke various pieces on the sites, this was not fun.

When implementing it on our sites and servers, I wanted a much lighter touch. Pagespeed should make things faster, and shouldn't make development slower.

Complicating matters was that we light to run our sites behind Varnish, the amazing HTTP accelerator. If you follow the default pagespeed setup guide for reverse proxies, then you end up disabling a lot of caching in Varnish.

After quite a bit of experimentation I've settled on the following base config for mod pagespeed:

# Do not change the application set caching headers.
ModPagespeedModifyCachingHeaders off

# Allow in place optimisation
ModPagespeedInPlaceResourceOptimization on

ModPagespeedRewriteLevel OptimizeForBandwidth

# Add some additional very safe filters.
ModPagespeedEnableFilters combine_css
ModPagespeedEnableFilters combine_javascript
ModPagespeedEnableFilters rewrite_images
ModPagespeedEnableFilters inline_css
ModPagespeedEnableFilters collapse_whitespace
ModPagespeedEnableFilters remove_comments

# Don't resize gifs or play with the favicon.
ModPagespeedForbidFilters convert_gif_to_png
ModPagespeedDisallow "*.ico"

# Rewrite URLs to allow further optimisation
ModPagespeedJsPreserveURLs off
ModPagespeedImagePreserveURLs off
ModPagespeedCssPreserveURLs off

This is a fairly conservative set of config, that makes some simple optimisations to CSS, JS and images, but without busting the Varnish cache.

So, you get the super serving speed of Varnish combined with the lovely optmisations from Mod Pagespeed, and no page breakage that we've noticed :)

Written by Steven Jones on Tuesday March 31, 2015
Permalink - Tags: pagespeed, apache, varnish, servers

Leave a comment

comments powered by Disqus

« Reflective spot counting - the start - Spot counting - JeeNode prototype »