Caching issue with Redis and HHVM


#1

Hello everyone, I’m having an issue with the caching of my website and I’m not sure where to begin. I have a very busy wordpress website on Digital Ocean with easyengine (redis + hhvm). I recently changed from php-fpm with fastcgi and w3 super cache, and the difference is incredible. I have the Nginx Helper and Redis plugin installed and activated properly on wordpress. When we post any new content, it takes a few hours (not sure the exact time yet) for a regular user to see the post on the front page (even if he/she clears all browser cache). The direct link to the post works ok.

If logged in, an admin or editor user can see the post on the front page just fine (as expected). Of course, if I purge the cache on the wordpress admin, the new post appears immediately on the front page for everyone. Like I said, I’m new to Redis and EasyEngine and I’m not sure where to begin to look for a fix for this small issue. Previously, I had W3 Super Cache which I believe cleared the cache every time a new post was published. Thank you in advance for any help!


#2

I’d love some extra info on this from what I’m reading, I use your former setup. PHP-fpm, FastCGI and w3tc.

I thought about going over to varnish, but I’ve not quite understood this hhvm thingi.

hopefully, someone will answer you sooner rather than later :smile:


#3

I have the same issue, using nginx helper plugin and redis cache. Setup nginx helper like it is supposed to be set up according to the installation guide here. The front-page will NEVER purge unless you clear the browser cache in firefox, chrome etc.

This is a big issue.

How are users supposed to know there is new content if the front-page is not showing the new posts automatically?


#4

Zero support and feedback.


#5

Why don’t you try the paid support?

Fortunately I never had any issue that I was not able to fix with help of community, but if someday I have one, I’ll certainly pay for specialized support.


#6

Why?

  1. because premium support is going to end anyway
  2. because this seems to be a common issue that does not just affect me.
  3. I have tested this with three independent server setups.
  4. The Nginx helper plugin is known for causing these issues, that has been reported in the past and never really got fixed.

#7

I have problem with HHVM too, HHVM will randomly stop response, and fall back to php-fpm after timeout (about 2-3min).

It will get back to normal after that.

I checked the error log and nothing special was found. I use php7-fpm now happily.

I suggest forget HHVM and use php7


#8

mrmad maybe I’m wrong, but I dont believe it is a common problem, as for as I know you are the first one having the same issue as me. Also my problem doesn’t go away by simply cleaning the user cache, I have to purge the server cache for it to work. I believe the problem can be related to the Nginx Helper, but I can’t find any additional info on that, or even how to check logs for each time I post. Anyway, if any of you guys can shed an additional light, it would be great!


#9

I may be into something. On the nginx-helper configuration, check your prefix. I was using "mywebsite.com (which is on the Redis config), but checking the nginx config itself, it seems that it uses “nginx-cache:” I changed and it seems to be working (algo enable logging on the nginx helper so you can check whats going on). Will update this post when I’m 100% sure it really works. Thanks!


#10

I was using nginx-cache as prefix (default value) and it did not purge. I haven’t made any changes to the easy engine config files, so seeing this happened with several servers I may well assume this can be a common problem.

The front-page will not purge for users that are not logged-in but previously visited the website. If they return to the front-page after some time to check if any new articles were published, they will still see the old front-page. They need to manually purge the cache in their browser on stumble upon the new published articles (as a related post, on a archive/category page) to see those changes reflected on the front-page eventually.


#11

I can confirm that fixing the prefix worked for me. Front page and all other pages are being purged from the cache when a new post occurs (the nginx helper log also confirms that), there is no more need for the user to clear cache or for me to manually purge the entire cache. Check your nginx configuration to make sure the prefix is set to “nginx-cache:” You should have something like: set $key “nginx-cache:…” under your redis-hhvm.conf


#12

Cool,

could you post your redis-php.conf or redis-hhvm.conf here? Maybe I am using a different one – I have been using hhvm since it was introduced in easyengine and it may not be updated correctly?

# Redis NGINX CONFIGURATION
# DO NOT MODIFY, ALL CHANGES LOST AFTER UPDATE EasyEngine (ee)
set $skip_cache 0;
# POST requests and URL with a query string should always go to php
if ($request_method = POST) {
  set $skip_cache 0;
}
if ($query_string != "") {
  set $skip_cache 1;
}
# Don't cache URL containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
  set $skip_cache 1;
}
# Don't use the cache for logged in users or recent commenter
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
  set $skip_cache 1;
}
# Use cached or actual file if they exists, Otherwise pass request to WordPress
location / {
 try_files $uri $uri/ /index.php?$args;
}

location /redis-fetch {
    internal  ;
    set  $redis_key $args;
    redis_pass  redis;
}
location /redis-store {
    internal  ;
    set_unescape_uri $key $arg_key ;
    redis2_query  set $key $echo_request_body;
    redis2_query expire $key 14400;
    redis2_pass  redis;

}

location ~ \.php$ {
  set $key "nginx-cache:$scheme$request_method$host$request_uri";
  try_files $uri =404;

  srcache_fetch_skip $skip_cache;
  srcache_store_skip $skip_cache;

  srcache_response_cache_control off;

  set_escape_uri $escaped_key $key;

  srcache_fetch GET /redis-fetch $key;
  srcache_store PUT /redis-store key=$escaped_key;

  more_set_headers 'X-SRCache-Fetch-Status $srcache_fetch_status';
  more_set_headers 'X-SRCache-Store-Status $srcache_store_status';

  include fastcgi_params;
  fastcgi_param HTTP_ACCEPT_ENCODING "";
  fastcgi_pass hhvm;
}

#13

Helpful thread, thanks guys


#14