How to set up Downstream Caches?

64 views
Skip to first unread message

Christian Bieser

unread,
Jul 1, 2014, 2:17:31 AM7/1/14
to ngx-pagesp...@googlegroups.com
Hi there! 
I am just trying to climb through in the instructions for configuring Downstream Caches <https://developers.google.com/speed/pagespeed/module/downstream-caching>. However, I do not see any common thread among the ports in the manual. Port 80 is assigned twice and there is no demonstrable link between nginx and varnish. 

My nginx listens on port 80 and serves content from varnish via port 8380 and varnish listens on port 8380 to serve content from the origin.

--- nginx.conf (truncated) ---
http {
  upstream varnish{
    server 127.0.0.1:8380
  }
  server {
    listen 80;
    server_name localhost;
    #pagespeed config removed for example
    location / {
      proxy_pass http://varnish;
      proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
      proxy_redirect off;
      proxy_buffering off;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
  }
}
---

--- varnish: run.sh ---
exec 2>&1
exec varnishd -F -s malloc,512M -u nobody -g nobody -p cli_timeout=30 \
  -f /etc/varnish/default.vcl -T 127.0.0.1:2000 \
---

--- varnish: backend.vcl ---
backend origin {
    .host = "originhost";
    .port = "80";
    .first_byte_timeout = 300s; # How long to wait before we receive a first byte from our backend?
    .connect_timeout = 5s; # How long to wait for a backend connection?
    .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?
}
---

How can all be brought together as Downstream Cache? 
Thanks and regards 
Christian

Joshua Marantz

unread,
Jul 1, 2014, 8:58:13 AM7/1/14
to ngx-pagesp...@googlegroups.com
Did you try setting up a block like this (from the doc):


pagespeed DownstreamCachePurgeLocationPrefix http://localhost:80;
pagespeed
DownstreamCachePurgeMethod PURGE;
pagespeed
DownstreamCacheRewrittenPercentageThreshold 95;


--
You received this message because you are subscribed to the Google Groups "ngx-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ngx-pagespeed-di...@googlegroups.com.
Visit this group at http://groups.google.com/group/ngx-pagespeed-discuss.
For more options, visit https://groups.google.com/d/optout.

Christian Bieser

unread,
Jul 1, 2014, 9:25:04 AM7/1/14
to ngx-pagesp...@googlegroups.com
According to the docs i have to write:
---
pagespeed DownstreamCachePurgeLocationPrefix http://localhost:8380;
pagespeed DownstreamCachePurgeMethod PURGE;
pagespeed DownstreamCacheRewrittenPercentageThreshold 95;
---
Am I wrong?

Joshua Marantz

unread,
Jul 1, 2014, 9:26:14 AM7/1/14
to ngx-pagesp...@googlegroups.com
Yes, that looks good.



--

Christian Bieser

unread,
Jul 1, 2014, 9:37:38 AM7/1/14
to ngx-pagesp...@googlegroups.com
Well, and what about the other parts in the doc? That's certainly not everything? 
For example, Configuring Varnish servers: run and backend default. Varnish is listening on port 80, nginx (Pagespeed​​) on 8080. Port 8080 is not mentioned above in the doc. Instead nginx is listening already on port 80...

Jeff Kaufman

unread,
Jul 1, 2014, 9:58:54 AM7/1/14
to ngx-pagesp...@googlegroups.com
It sounds like you're running nginx in front of varnish. Your structure is:

[origin] -> [varnish] -> [nginx] -> [user]

The downstream caching docs are for people who have things set up as:

[origin] -> [nginx] -> [varnish] -> [user]

In your setup, with no cache between nginx and the user, you don't
need to configure downstream caching at all.

Christian Bieser

unread,
Jul 1, 2014, 10:56:32 AM7/1/14
to ngx-pagesp...@googlegroups.com
In the meantime, I finally understood that Google has described in the docs two types of downstream caches. I had the perceived differently. 

It works now. Just not on SLES (Segmentation fault in PSOL) ...

Jeff Kaufman

unread,
Jul 1, 2014, 11:42:37 AM7/1/14
to ngx-pagesp...@googlegroups.com
If you could a start a new thread with the details of your segfault on
SUSE I'd be happy to look at it.

Christian Bieser

unread,
Jul 2, 2014, 5:30:02 AM7/2/14
to ngx-pagesp...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages