6 ms·
Speed up your sites with PageSpeed for Nginx
- cbr 14y agoComments from when someone posted a link to a pre-alpha version: https://news.ycombinator.com/item?id=4638712 https://news.ycombinator.com/item?id=4638712
- JeremyMorgan 14y agoThis is pretty sweet. What optimizations does it do other than offloading stuff to CDN?
- zippykid 14y agoJeremy, image optimization/compression, javascript minification/combination etc are some of the benefits we've tested and had tremendous success with.
- cbr 14y agoAll these: https://developers.google.com/speed/docs/mod_pagespeed/filters https://developers.google.com/speed/docs/mod_pagespeed/filte... So image optimization, css and js minification, cache extension, css combining, image spriting, ... But offloading things to CDN is actually one of the things it doesn't do. You might be thinking of the PageSpeed Service [1] which is a Google-hosted version. [1] https://developers.google.com/speed/pagespeed/service https://developers.google.com/speed/pagespeed/service
- icelancer 14y agoWow. Thanks for bringing the service to my attention! Cut the load times on my sites by a ton.
- igrigorik 14y agoYou can see the complete list of filters (40+) here: https://developers.google.com/speed/docs/mod_pagespeed/config_filters?hl=nl https://developers.google.com/speed/docs/mod_pagespeed/confi... Note that docs above are for mod_pagespeed (Apache), but all of the same filters are available in nginx port as well - it's the same C++ code under the hood. In a nutshell: HTML, CSS, JS, and image optimization (resizing, recompression, WebP, auto-spriting, etc...) Configuring ngx_pagespeed: https://github.com/pagespeed/ngx_pagespeed#how-to-use https://github.com/pagespeed/ngx_pagespeed#how-to-use
- JeremyMorgan 14y agoThank you that's more helpful. Looks like a great tool
- nodesocket 14y agoI wish I didn't have to compile from source to install modules, I'd love to continue to use the official nginx YUM repo.
- cbr 14y agoYou can do this with Tengine [1], a version of Nginx that supports loadable modules: https://github.com/pagespeed/ngx_pagespeed/wiki/Using-ngx_pagespeed-with-Tengine https://github.com/pagespeed/ngx_pagespeed/wiki/Using-ngx_pa... [1] http://tengine.taobao.org/ http://tengine.taobao.org/
- yareally 14y agoIf you're using Debian, dotdeb[1] comes with the ngnix-extras (includes the push stream module[2]) installed as well as some other goodies like passenger. [1] http://www.dotdeb.org/2011/12/19/nginx-1-0-11-passenger-3-0-11-and-push-stream-support/ http://www.dotdeb.org/2011/12/19/nginx-1-0-11-passenger-3-0-... [2] https://github.com/wandenberg/nginx-push-stream-module https://github.com/wandenberg/nginx-push-stream-module
- druiid 14y agoDoes anyone know if this works when using Nginx as a proxy? That would be pretty killer if so.
- cbr 14y agoIt does; that's definitely one of the intended uses.
- igrigorik 14y agoYup, in fact, that's exactly how ZippyKid integration is setup: https://www.zippykid.com/2013/04/23/partnership-with-google-to-deliver-fast-wordpress-sites/ https://www.zippykid.com/2013/04/23/partnership-with-google-... It doesn't matter if the files are local or remote, ngx_pagespeed can fetch from both. Some docs on related functionality: https://developers.google.com/speed/docs/mod_pagespeed/domains https://developers.google.com/speed/docs/mod_pagespeed/domai...
- druiid 14y agoThanks for the link. I for one will be implementing this then! Probably start testing tonight actually (I'm excited).
- zippykid 14y agoDruiid, do you mind testing our instructions here? http://github.com/zippykid/nginx/ http://github.com/zippykid/nginx/ ?
- thejosh 14y agoI kept tripping up on the instructions, such as the git clone for your repo should be the anon one (git://) and final commands (debuild -us -uc) kept telling me that there were no upstream git. I tried the scripts verbatim on a fresh Ubuntu 13.04 VM (64bit). edit: Your deb link at the end of the readme is broken as well.
- 14y ago
- joevandyk 14y agoI'm hoping heroku can support this. Maybe via a buildpack. I'd love to get rid of using Sprockets and compiling assets. ngx_pagespeed should take care of everything Sprockets does, right?
- igrigorik 14y agoYep, it'll concatenate files, minify them, etc., all the things you would expect. Perhaps the only caveat is: it doesn't do any dependency management, etc., which sprockets provides (if you actually use that part of it).
- ushi 14y agoOooops, http://ngxpagespeed.com/ http://ngxpagespeed.com/ (their demonstration site) doesn't respond at the moment...
- dantiberian 14y agoWouldn't it be preferable to perform all of these optimizations once before page load to reduce the work that nginx has to do?
- dangrossman 14y agoThe work only has to be done once either way; all the file-based optimizations get cached, they're not run again on every page view.
- jedberg 14y agoIf I have a static directory of files is there any way to leverage this same code to just perform the optimizations on my html so I don't have to have the webserver do it (or so I don't have to run my own webserver)?
- buymorechuck 14y agoProbably not without some work. I think you have to get the PageSpeed Optimization Library and build it from source, as described here: https://github.com/pagespeed/ngx_pagespeed/wiki/Building-PSOL-From-Source https://github.com/pagespeed/ngx_pagespeed/wiki/Building-PSO... (hi!)
- jedberg 14y agoHmmm. I don't really know C++ well enough to do this myself. Oh well. Seems like it would be super useful to have a command line version of this so I could take an html file, pipe it in and get out an optimized file, and then diff them so I can learn to make my pages better. I suppose as a hack I could set up nginx with the plugin and then load each page through curl or something and diff them that way...
- skrebbel 14y agoThat wouldn't be a 100% match since it assumes HTTP headers and mangles them, too. For example, it probably uses the MIME type served by the proxied server to see whether it's css or js or whatever should be minified (I didn't check the sources for this). With a pipe, it'd need to use heuristics to figure out what kind of file it is. That could be added, probably, but it's not entirely trivial. Additionally, you'd miss out on all the HTTP header mangling, such as cache expiry settings.
- deleted 14y ago[deleted]
- jamengual 14y agoInstructions on how to install/build deb package for Ubuntu/Debian here http://serverfault.com/questions/502764/how-to-build-nginx-1-4-0-and-ngx-pagespeed-in-ubuntu http://serverfault.com/questions/502764/how-to-build-nginx-1...
- shawabawa3 14y agoThis didn't work for me, it did something very strange. I have nginx set up to listen on ssl and proxy everything to my python backend in plain http (as well as serve static files) Installing the pagespeed module (without even turning it on), caused nginx to revert to the default config (it just served the default nginx index.html and 404'd everything else) after the 3rd or 4th request. Any ideas why this would happen?
- ludwigvan 14y agoI had the same issue, even with the same config file, with no pagespeed directive, the version with the pagespeed module failed for static files for me. [0426/064031:INFO:google_message_handler.cc(33)] Shutting down ngx_pagespeed root
- cbr 14y agoI'm debugging this now. If you have anything atypical about your setup it would be great if you could post it to the bug: https://github.com/pagespeed/ngx_pagespeed/issues/292 https://github.com/pagespeed/ngx_pagespeed/issues/292
- cbr 14y agoI've narrowed down the problem to a specific change, and updated the installation instructions to use a release from last week before that change. People are reporting that this fixes it for them. I'm going to be putting out an updated version, probably 1.5.27.2, that also will have this issue fixed.
- growse 14y agoThis is brilliant, in principle. Getting some odd segfaults to do with libpthread-2.15.so on Ubuntu 12.10 though, so not sure what's going on there. I'll dig some more then file a bug...
- perlgeek 14y agoAm I the only one who is worried that modules like this introduce subtle and hard-to-find bugs in the served pages? It's a layer you don't usually look at when debugging web applications.
- skrebbel 14y agoGood one. Anyone here got experience with the original Apache mod_pagespeed in production?
- Scottopherson 14y agoI've been thinking the same thing. Although, reading about how it works does help alleviate my concerns somewhat: https://github.com/pagespeed/ngx_pagespeed/wiki/Design https://github.com/pagespeed/ngx_pagespeed/wiki/Design. At the least, it seems like something worth playing around with.
- zufallsheld 14y agoI tried it on my own little webpage [1]. Results in short: 0.5 seconds to 0.9 seconds shorter load times. Beware, that I only have static content on that website. [1] http://zufallsheld.de/2013/04/26/googles-nginx-plugin-ngx_pagespeed-tested/ http://zufallsheld.de/2013/04/26/googles-nginx-plugin-ngx_pa...