Server Setup

Do what PageSpeed module does, without PageSpeed module

by , , revisited on

We have by far the largest RPM repository with NGINX module packages and VMODs for Varnish. If you want to install NGINX, Varnish, and lots of useful performance/security software with smooth yum upgrades for production use, this is the repository for you.
Active subscription is required.

The PageSpeed module (ngx_pagespeed, for NGINX) is there to optimize your website client-side performance automatically.

However, it does make a burden on your CPU and RAM with every request. By its nature, it always does stat calls to cache extended and optimized resources. So if in case of PHP OPCache you can do revalidate_timestamps set to Off, there is no such magical switch for PageSpeed’s cache.

Why PageSpeed module is good

The primary benefits of PageSpeed module are those things that can not be easily configured in NGINX:

  • Optimize images and serve WebP images for supporting browsers
  • Minifying CSS and Javascript files
  • Concatenating assets (no longer needed, really in an HTTP/2 world)

In this (now stub) post, I will give an overview of methods to achieve what PageSpeed module does, all without using it and even better 🙂

As long as your website development follows a proper development workflow, you can quite easily optimize everything without the PageSpeed module.

Ideally, you implement a git workflow for your website, and optimizing client-side performance is done:

  • once at the very beginning
  • upon every deployment

Simply put, the optimizations are done only when they’re actually needed – during deployment; as opposed to PageSpeed module’s approach, which is on every request.

Our optimizations during deployment would include:

  • CSS files modification: generating .min suffixed CSS files
  • Compressing images
  • Generation of .webp versions of images

Optimize images

You can optimize website images automatically.

Minify CSS and Javascript files

You can use Closure Compiler for Javascript files. To install it in CentOS 7:

yum install https://extras.getpagespeed.com/release-latest.rpm
yum install closure-compiler
  1. NearlyNormal

    It would be good to have some more info on how to use this. Will CSS/JS be auto-minified and combined? Will WebP work automatically?

  2. katz

    I agree with NearlyNormal, this information is limited. I came on this page several times to combine information with other sites out there. I still haven’t figured out how the minification works


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.