Google Pagespeed module for nginx

Events happening in the community are now at Drupal community events on www.drupal.org.
brianmercer's picture

A couple weeks ago a Google Pagespeed module for nginx was released as beta. It has some interesting filters that process things like css files, js files, images, html and headers. See https://developers.google.com/speed/docs/mod_pagespeed/filters

I added it to a test version of my Ubuntu 12.04 nginx package on Launchpad. You can install it with

add-apt-repository ppa:brianmercer/testing
aptitude update
aptitude install nginx-pagespeed

then create a directory for it (I'll do this in the package eventually)
mkdir /var/cache/nginx/pagespeed
chown www-data /var/cache/nginx/pagespeed

and add some directives to your nginx server{} section
pagespeed on;
pagespeed FileCachePath /var/cache/nginx/pagespeed;
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
  add_header "" "";
}
location ~ "^/ngx_pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
location /ngx_pagespeed_statistics {
  allow 127.0.0.1; deny all;
}
location /ngx_pagespeed_message {
  allow 127.0.0.1; deny all;
}

Many of these optimization techniques we already do by hand. I don't have any impressions of it yet, except that the idea of doing some of these things at the web server level is interesting.

Let me know if you have any problems with the package.

Comments

How can I install it if I

superfedya's picture

How can I install it if I compile Nginx from the source?

There are instructions in the

brianmercer's picture

There are instructions in the README. https://github.com/pagespeed/ngx_pagespeed

Hmm, I guess I'm doing something wrong...

Gwyneth Llewelyn's picture

So I did add-apt-repository ppa:brianmercer/testing, and that certainly worked.

But then, when running aptitude, I only get:

Couldn't find any package whose name or description matched "nginx-pagespeed"

What step am I missing here?

I'm just a virtual girl in a virtual world...

Only local images are allowed.

ah yes, it needs this in

brianmercer's picture

ah yes, it needs this in there:

aptitude update

Works great! Do I need a

superfedya's picture

Works great!
Do I need a Advanced CSS/JS Aggregation module anyway or it's useless?

But now CPU load is much

superfedya's picture

But now CPU load is much higher for Nginx. It's temporary or permanent?

Those are both good

brianmercer's picture

Those are both good questions. I'm still experimenting with and evaluating this module. That's good to know about the CPU load.

Now cpu load is decreased. Do

superfedya's picture

Now cpu load is decreased.
Do we really need drupal's css/js optimisation modules or Google page speed can handle all this?

Nginx

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: