Google PageSpeed for nginx: what it did, how it ended and what replaces it

In short: the Google PageSpeed module for nginx (ngx_pagespeed) has had no upstream development since the Apache Incubator retired it in March 2023. We still build it for current nginx and Angie so existing sites keep working, but new setups should not use it. This post shows what it did, what replaces each feature, and how to remove it without breaking old links.

PageSpeed Insights is not the PageSpeed module

The name “PageSpeed” covers two different things, and people mix them up all the time.

  • Google PageSpeed Insights is the website at pagespeed.web.dev. It scores your page and lists what to fix. It is a measurement tool, and it is still alive.
  • mod_pagespeed and ngx_pagespeed are server modules for Apache and nginx. They applied many of those fixes on the server, automatically. This post is about these modules.

Insights tells you what is wrong. The module tried to fix it for you, on every response, without changes to your code.

Google released mod_pagespeed for Apache in 2010 and ngx_pagespeed for nginx a few years later. The idea was simple: let the web server make the site faster, with zero changes to the site itself.


What the PageSpeed module did

The module sat in nginx’s output path. It read each HTML page on its way out, rewrote it, and served optimised copies of the CSS, JavaScript and images it referenced. These were its main tricks.

Minification

CSS and JavaScript files carry spaces, line breaks and comments written for humans. Browsers do not need them. PageSpeed stripped them out on the fly and served the smaller copy.

Image optimisation

PageSpeed recompressed images, resized them to the size the page displays, and converted them to WebP for browsers that accept it. Visitors on a phone no longer downloaded a full camera photo.

Inlining

A small CSS or JavaScript file costs an extra request. PageSpeed copied small files straight into the HTML, so the page needed fewer round trips before it could render.

Cache extension

PageSpeed renamed every optimised file with a content hash. A file name changes when its content changes, so browsers can cache it for a long time without ever seeing a stale copy.

This is what the new names look like on our current package. We ran it on a test page with one stylesheet, one script and one 800×600 image shown at 400×300:

style.css  ->  A.style.css.pagespeed.cf.aCLjKvEB7T.css
app.js     ->  app.js.pagespeed.jm.6LHhBvG4YT.js
photo.png  ->  400x300xphoto.png.pagespeed.ic.ZLF-54_660.webp

PageSpeed shrank the image to the displayed size and converted it to WebP. Remember these names. They matter when you remove the module.

Lazy loading and compression

PageSpeed could delay images below the fold until the visitor scrolled to them. It also kept compressed copies of its rewritten files in its own cache. Today nginx can compress with Brotli or zstd directly, as shown further down.

In short, PageSpeed did on the server what a front-end build pipeline does today. For its time, it was clever engineering.


How PageSpeed went from popular to retired

From about 2012 to 2018, ngx_pagespeed was a common sight on nginx servers. It was free, it ran on your own server, and the default settings made a slow WordPress site feel faster. For a small shop without a CDN or a build pipeline, that was a real gain.

Then the rest of the web caught up.

Build tools and CDNs did the same work

Build tools such as webpack, esbuild and Vite now minify and bundle files once, at build time. That is better than doing it at request time: the work happens once, and you control the result. CDNs added image resizing and caching at the edge, with no server module to compile.

HTTP/2 and Core Web Vitals changed the rules

Some PageSpeed tricks were built for HTTP/1.1. One optional feature spread files over extra host names (domain sharding) so old browsers could download more in parallel. HTTP/2 sends everything over one connection, so sharding only adds connections.

Google’s own metrics moved on as well. Core Web Vitals measure Largest Contentful Paint (LCP), Interaction to Next Paint (INP) and Cumulative Layout Shift (CLS). INP replaced First Input Delay in March 2024. Minifying a stylesheet does little for these numbers, and careless inlining can make layout shift worse.

Hard to debug

When a rewrite went wrong, it was hard to see why. A broken image or a flash of unstyled content could come from any of dozens of filters. The logs rarely said which one.


How the project ended

Google moved mod_pagespeed and ngx_pagespeed to the Apache Software Foundation in 2017. They entered the Apache Incubator on 30 September 2017 as the PageSpeed podling. Development slowed, and the podling retired on 17 March 2023.

Retired means no upstream releases and no upstream security fixes. If someone finds a flaw in PageSpeed or its PSOL library today, nobody upstream will patch it. That alone is a good reason to plan your way off it.


PageSpeed on nginx and Angie today

Many guides say ngx_pagespeed no longer builds against modern nginx. That is not true for the packages on deb.myguard.nl. We still build it for every supported Debian and Ubuntu release:

  • libnginx-mod-pagespeed for nginx (version 1.31.10 in the index on 23 November 2026)
  • angie-module-pagespeed for Angie (version 1.12.5)

Upstream Angie does not bundle PageSpeed; our module package adds it. In a test container, our nginx build loaded the module, rewrote pages and reported X-Page-Speed: 1.15.0.0-8926.

We keep these packages so existing sites can upgrade nginx without losing their setup. They are not a recommendation for new sites. If PageSpeed stops building against a future nginx release, we will drop it rather than port it.

The PageSpeed documentation archive lives at pagespeed.myguard.nl. If you need to rebuild the PSOL library for a legacy install, the build scripts are in github.com/myguard-labs/build_psol.


What replaces each PageSpeed feature

Most of what PageSpeed did now has a simpler home: the build step, the CMS, or a small nginx module. This list maps each feature to its replacement and to the package in our repository, where one exists. Angie packages use the angie-module- prefix instead of libnginx-mod-.

Diagram mapping each Google PageSpeed module feature to its replacement: compression to the Brotli and zstd nginx modules, minify and combine to a build tool or CMS plugin, image rewriting to optimising on upload, cache extension to hashed file names with long Cache-Control, lazy loading to loading=lazy, and its rewrite cache to FastCGI cache with purge
Each PageSpeed feature and what replaces it today.
  • Compression of rewritten files: Brotli or zstd in nginx. Packages libnginx-mod-http-brotli and libnginx-mod-http-zstd.
  • Minify and combine CSS and JavaScript: a build tool or a CMS plugin. libnginx-mod-http-concat can combine files, but only if you change the HTML.
  • Recompress, resize and convert images: optimise on upload. If you must resize on request, use libnginx-mod-http-image-filter (resize and crop).
  • Cache extension (hashed names): hashed file names from the build tool and a long Cache-Control lifetime.
  • Lazy loading: the loading="lazy" attribute in HTML, which browsers support natively.
  • Its own cache of rewritten files: FastCGI or proxy cache, with libnginx-mod-http-cache-purge to purge it.

Compression: Brotli and zstd

Our nginx packages ship both compression modules as separate packages. Install them with apt install libnginx-mod-http-brotli libnginx-mod-http-zstd, then add a small file to the http context:

# /etc/nginx/conf.d/compression.conf (http context)
# needs: apt install libnginx-mod-http-brotli libnginx-mod-http-zstd
brotli on;
brotli_comp_level 5;
brotli_types text/css application/javascript application/json image/svg+xml text/plain text/xml;

zstd on;
zstd_comp_level 3;
zstd_types text/css application/javascript application/json image/svg+xml text/plain text/xml;

With this file in conf.d, our test server answered CSS and HTML with Brotli or zstd, depending on what the client asked for. Browsers that support neither still get gzip from the stock config. For a comparison of the three, see zstd vs Brotli vs zlib-ng and the Brotli module guide.

Images: optimise on upload

Do the image work once, when the file is uploaded, not on every request. Tools such as Squoosh or ImageMagick do this by hand. On WordPress, a plugin such as EWWW Image Optimizer or ShortPixel converts and resizes images on upload.

If you need resizing on request, the image filter module can resize and crop. A CDN with image transformation, such as Cloudflare Images or Bunny Optimizer, is another option.

Minification: build tools or a plugin

If you control the code, let Vite, esbuild or webpack minify CSS and JavaScript at build time. The server then serves plain static files with no per-request work.

If you run WordPress or another CMS, a caching or optimisation plugin can minify instead. Note that Cloudflare retired its Auto Minify feature in 2024, so older guides that tell you to switch it on no longer apply.

Caching: FastCGI cache

PageSpeed cached its rewritten files on disk. nginx’s FastCGI cache stores whole pages instead, which is simpler and saves far more work. The nginx and Angie optimisation guide covers the setup, and nginx-cache-turbo adds faster cache tiers.

Everything at once: a CDN

For many sites, a CDN in front of the server covers caching, compression and HTTP/3 in one step. Cloudflare’s free plan is enough for a lot of them, although some image features are paid. PageSpeed was, in effect, a CDN emulator for one server.


How to remove PageSpeed without breaking old links

Measure first. Run PageSpeed Insights on a few key pages, note the scores, and keep the numbers for later.

Then work through these steps:

  1. Remove the module: apt-get remove libnginx-mod-pagespeed (or angie-module-pagespeed on Angie).
  2. Delete every pagespeed line from your config, including any include of pagespeed_libraries.conf. With one line left, nginx -t fails with unknown directive "pagespeed", and a reload or restart fails too.
  3. Add the redirect below to each server block that used PageSpeed.
  4. Add the Brotli and zstd file from the previous section.
  5. Run nginx -t, reload nginx, then run PageSpeed Insights again and compare.
  6. Once nginx runs without the module, delete the old cache in /var/cache/pagespeed (or your FileCachePath).

Step 3 is the one most guides skip. Browsers, CDNs and search engines still hold pages that point to the rewritten names shown earlier. Once the module is gone, those URLs return 404, which means broken styles in cached pages and lost images in search results.

This redirect sends each old name back to the original file:

# server context: send old PageSpeed URLs back to the original file
# resized or converted image: 200x150xphoto.png.pagespeed.ic.HASH.webp -> photo.png
location ~ "^(?<dir>.*/)(?:A\.)?(?:\d+x\d+)?x(?<file>[^/]+)\.pagespeed\.ic\.[^./]+\.[a-z]+$" {
    return 301 $dir$file;
}
# CSS, JavaScript and cache-extended files: style.css.pagespeed.cf.HASH.css -> style.css
location ~ "^(?<dir>.*/)(?:A\.)?(?<file>[^/]+)\.pagespeed\.[a-z]{2}\.[^./]+\.[a-z0-9]+$" {
    return 301 $dir$file;
}

In our test, after removing the module, all three rewritten names from the earlier example returned a 301 to style.css, app.js and photo.png, and each target returned 200. Ordinary file names do not match, so normal requests are not affected.

There is one limit. Files that PageSpeed combined (names with several parts joined together) cannot be mapped back to one original, so they still end in a 404. Keep the redirect for a few months, until search engines and caches have picked up the new pages.

When to keep it for now

Keeping PageSpeed for a while is reasonable in a few cases:

  • The site is frozen: no changes planned and no time to replace the features.
  • It is a legacy site that is about to be retired anyway.
  • You removed it in staging and the Insights scores got worse. Then replace the missing features first, and remove it after.

In every other case, remove it. A site without PageSpeed but with compression, cache headers and optimised images usually scores as well or better, with one less unmaintained module in the request path.


Related posts

If your site needs to go faster, these are good next steps:


PageSpeed documentation archive: pagespeed.myguard.nl. The compression modules, cache modules and the rest of our nginx and Angie packages are at deb.myguard.nl.