1

I currently have the following set-up:

Nginx (https) => ssl offloaded => Varnish (http) => Apache (http)

I want to add mod_pagespeed or nginx pagespeed in the mix. Any ideas where to add it? Should I look into adding pagespeed to Apache or to Nginx?

The following page has some information, but I'm unsure what to do with our specific set-up.

https://developers.google.com/speed/pagespeed/module/downstream-caching

I was thinking of exploring one of the following options:

Add pagespeed to nginx, making pagespeed use the cached pages from varnish / apache and executing on the fly Add pagespeed to Apache, and configuring it in such a way that the pages get cached based on user agent / screen resolution. If I understand correctly, the artice I point out above refers to the second option. It might be easier to set up the first option though I think?

Thanks in advance for the help!

3
  • I read somewhere that pagespeed wasn't that useful any more. What are you trying to achieve - what do you think pagespeed is going to do for you? Nginx can do page caching and header rewriting relatively easily, personally I just use nginx with PHP. Why are you using nginx, varnish, apache, and presumably something behind Apache like PHP?
    – Tim
    Jan 25, 2016 at 22:14
  • I'm using nginx as a reverse proxy in front of varnish, because varnish doesn't support SSL. Google Pagespeed doesn't do caching, it optimizes js / css delivery and rewrites HTML by placing non-critical assets at the bottom of the page. Google pagespeed is for the front-end delivery, not for back-end / caching. Jan 25, 2016 at 23:16
  • So to elaborate: The caching already works fine, but I want to use google pagespeed for optimized images based on device / resolution, and optimizing front-end asset delivery. Jan 25, 2016 at 23:23

3 Answers 3

1

I would probably add PageSpeed to Apache. That way the pages are optimised once, cached in Varnish, and served out by Nginx. This will be more efficient, reducing CPU use, if you put PageSpeed on Nginx it may have to do it on every request.

Note: this is based on the documentation I've read, not practical experience.

2
  • The problem is that in this case varnish should keep optimized pages per user agent / resolution which might be difficult to set up. That's why I'm wondering if using pagespeed for nginx would be a more simple solution. Jan 25, 2016 at 23:52
  • 1
    Caches can typically be configured for this using the Vary and Accept-Encoding headers : maxcdn.com/blog/accept-encoding-its-vary-important
    – Tim
    Jan 25, 2016 at 23:57
1

To use the Nginx PageSpeed module, you have to recompile Nginx to install it, and then keep recompiling Nginx each time there is an update to PageSpeed or Nginx that you need to make. By contrast, Apache can load the PageSpeed code as external module, making the Apache route easier to manage.

I just went through installing Nginx PageSpeedd. Adding it with the default settings only bumped our PageSpeed Insights score by 4 ports out of 100.I decided it wasn't worth maintaining custom packages for the relatively modest gain. Also, the Nginx PageSpeed module caused a /slowdown/ in delivery noticed by the PageSpeed Insights tool, presumably due to the CPU overhead of the content filtering that it's doing. I had to install a Wordpress caching plugin to mitigate that.

1
  • 1
    Thanks! In that case it might be worth it to look into configuring pagespeed with apache indeed. We're using varnish as an FPC so probably the CPU overhead wont be much. However, using the mod_pagespeed route seems easier like you point out. Jan 26, 2016 at 2:44
0

I'm not sure what is the best way to integrate those products as I do not know Varnish yet.

However, this is where I get the pagespeed modules. https://www.getpagespeed.com/redhat

I do most of the stuff in NGINX.

The pagespeed extended cache has some kewl features and I think they can be integrated in to the mix with varnish.

I also found this which may be usefull https://gist.github.com/section-io-gists/dcda5a05d1006e3b8c8bd17e7105749c

oh and lets not forget Brotli compression https://www.getpagespeed.com/server-setup/nginx/install-nginx-with-brotli-module-in-centos-redhat-7

I am going to try:

NGINX (SSL Termination,PageSpeed, PageSpeed Cache, Brotli) <-- Varnish <-- Apache (Application)

It may be smarter to move the pagespeed stuff to Apache tho

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .