How to configure properly a site with --wpredis?

Hello there,

I followed the instructions of installing wordpress with --wpredis option to cache the site, but this setup is not working.

Is there something missing in the tutorial?

I do see that some, not all of the pages are being cached by redis, but when I look at the header this is what I get:

X-Cache: MISS X-Cache-2: BYPASS X-Powered-By: EasyEngine 3.3.0 Date: Wed, 22 Jul 2015 14:23:41 GMT X-Page-Speed: 1.9.32.4-7251 Cache-Control: max-age=0, no-cache

at first I thought HHVM was causing the issue, so I went and setup a new server from scratch using just ee site create xxx.xxx --wpredis, but I’m still getting the same results.

I think it’s because you’re logged in when you access the site and view the headers, hence the bypass. I can see my test site being successfully cached via --wpredis however if I install with HHVM I’m pretty convinced something’s wrong.

See this post of mine

Ok, I think I figured it out.

I changed in redis-hhvm.php file the set $key variable from

#set $key "nginx-cache:$scheme$request_method$host$request_uri";
  set $key "nginx-cache:http://$host$request_uri";

And now I’m getting hits instead of misses

1 Like

try what I just did. I have hhvm enabled and I’m getting hits now.

Hmmm. Just did and nothing. What version HHVM and do you have the redis-cache plugin enabled?

Did you mean redis-hhvm.conf?

I did try your code but it still isn’t working :frowning:

sorry, yeah I meant redis-hhvm.conf.

HipHop VM 3.8.0 (rel)
Compiler: tags/HHVM-3.8.0-0-gbb32f8d645b28561d8491870c44730b9b3f08d35
Repo schema: 74bee5d310450724cfd49245fd6c2e1e4323b10a

I think the problem is in that line. I just changed the settings on a live server and noticed that if I click any of the links from the homepage it won’t cache it, but if I click on any of the links from within the site (a post) it does.

curl -I http://sonfamosos.com/2014/10/20/murio-el-disenador-oscar-de-la-renta/
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 22 Jul 2015 15:41:53 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 36663
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: HHVM/3.8.0
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Vary: Accept-Encoding
Pragma: no-cache
X-Pingback: http://sonfamosos.com/xmlrpc.php
Link: <http://sonfamosos.com/?p=919>; rel=shortlink
X-Cache: HIT
X-Cache-2: BYPASS
X-Powered-By: EasyEngine 3.3.0

@angelgmartinez

can you give us output for curl -I -X GET http://example.com

replace example.com with your site.

This is using the previous URL:

curl -I -X GET curl -I http://sonfamosos.com/2014/10/20/murio-el-disenador-oscar-de-la-renta/
curl: (6) Could not resolve host: curl
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 22 Jul 2015 15:52:16 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 36663
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: HHVM/3.8.0
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Vary: Accept-Encoding
Pragma: no-cache
X-Pingback: http://sonfamosos.com/xmlrpc.php
Link: <http://sonfamosos.com/?p=919>; rel=shortlink
X-Cache: HIT
X-Cache-2: BYPASS
X-Powered-By: EasyEngine 3.3.0

This is using just the domain:

$ curl -I -X GET http://sonfamosos.com
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 22 Jul 2015 15:55:11 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 47443
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: HHVM/3.8.0
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Vary: Accept-Encoding
Pragma: no-cache
X-Pingback: http://sonfamosos.com/xmlrpc.php
X-Cache: HIT
X-Cache-2: BYPASS
X-Powered-By: EasyEngine 3.3.0

Is that output with the default cache key?

I’m finding that using curl, I can achieve this:

curl -I -X GET http://zoomhhvm.ee   

HTTP/1.1 200 OK
Server: nginx
Date: Wed, 22 Jul 2015 16:01:02 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 8722
Connection: keep-alive
Vary: Accept-Encoding
Vary: Accept-Encoding 
X-Pingback: http://zoomhhvm.ee/xmlrpc.php
X-Powered-By: HHVM/3.8.0
X-Cache: HIT
X-Cache-2: BYPASS

however trying the same in a browser (Chromium) then the page is never stored.

@harshadyeola

ok so this is what I did since I have multiple sites on the same server.

I copy redis-hhvm.conf to site-redis-hhvm.conf and made the adjustments on the /sites-available/site file to include site-redis-hhvm.conf instead of redis-hhvm.conf.

I went into site-redis-hhvm.conf and replaced the default key form

set $key "nginx-cache:$scheme$request_method$host$request_uri"; to set $key "site:http://$host$request_uri";

I’m currently testing with the new $key, so the answer I’m not using the default key.

using the default key?

@angelgmartinez If you mean me, yes.

@DaveNaylor: sorry, yes

are you using phpRedisAdmin to look at redis?

@angelgmartinez “redis-cli” in a terminal, then “monitor”

@DaveNaylor

I guess you are talking about X-Cache-2: BYPASS.

as you are already having page inside cache so you are getting BYPASSeach time.

@harshadyeola No what I mean is, I’m getting differing results when using curl than I am using a web browser. If I hit a page with curl, the data is being stored then fetched from the cache on subsequent visits. If I use a browser, the page data is not being stored.

@angelgmartinez I managed to get HHVM and --wpredis playing nicely, details on my related post

1 Like