Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.
jeffkaufman edited this page Dec 21, 2012 · 12 revisions

Accurate as of 2012-12-21

Most of ngx_pagespeed is glue code, attaching PageSpeed to Nginx. What's attached to what, and how does it work?

The two main places we interact with an Nginx request are in a body filter and a content handler. In the body filter we pass html to PageSpeed for optimizing, while in the content handler we respond to requests for optimized PageSpeed resources (css, images, javascript). An example might be helpful.

  1. Nginx receives a request for http://example.com

     GET / HTTP/1.1
     Host: example.com
    
  2. Nginx calls our content handler [^1], which declines to handle the request because it's not for an optimized .pagespeed. resource.

  3. Nginx continues trying other content handlers until it finds one that can handle the request. This may be a proxy_pass, fastcgi_pass, a try_files, or anything else that the webmaster might have configured Nginx to use.

  4. Whatever content handler Nginx selects will

[^1] As tracked in Issue #102, our content handler is not always called first. This needs to be fixed, and this description assumes we've fixed it.

Clone this wiki locally