We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Getting memcached to clear -- faulty setting or other issue?

How Do I?

Linda A's avatar
Linda A
647 posts
8 years ago
Linda A's avatar Linda A

I am running into some issues with memcached, so I am wondering if anyone else has had a similar experience? Sometimes content doesn’t update on the site for significant amounts of time – sometimes an hour, it feels like. But if we restart memcached, suddenly the update is present. Is there a setting we could have wrong that prevents it from being properly purged when a template is changed or new content added?

This might be more of a support question, of course, but I figured I’d check to see if the answer is out there somewhere first.

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Can you specify how you are caching content, and what actions you are doing to trigger a cache clear?

       
Linda A's avatar
Linda A
647 posts
8 years ago
Linda A's avatar Linda A

Do you mean how we’re caching data outside of EE? Or the template settings?

In terms of clearing the cache, I’ve tried clearing “all caches” via clear cached data, as well as editing templates and posting new content. None of these trigger a clearing of memcached.

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

I mean, template cache (if so, please share the settings), tag cache (if so, please share your code), third-party cache add-on, etc.?

       
Linda A's avatar
Linda A
647 posts
8 years ago
Linda A's avatar Linda A

A page that had this issue was http://www.westeros.org/GoT/News.

The template for that is set to Yes for caching, and 60 minutes time.

In Template Preferences, we have “Do Not Change”. I’m guessing setting that to ‘No’ would override caching settings for all individual templates?

I don’t use any tag caching or caching add-ons. 3rd party caching on the server itself includes Cloudflare (but the issue persists if we go into Development mode), Varnish (however, we pass straight through Varnish so do not use it for caching), and memcache (which seems related to the issue)

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Ok are you in v2? I thought you had upgraded to v3.

As a gut check, if you change the caching driver to Redis or file-based, do you have the same issue?

       
Linda A's avatar
Linda A
647 posts
8 years ago
Linda A's avatar Linda A

Yeah, still V2, have some add-ons I haven’t sorted out yet. We don’t have Redis, but will try file-based and report back.

       
Linda A's avatar
Linda A
647 posts
8 years ago
Linda A's avatar Linda A

And file-based works, changes come through right away, though as I understand it is not ideal?

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Yeah file-based caching, especially on a large site with frequent global scope cache clearing events and heavy traffic, can introduce some resource drain on disk i/o having to delete and recreate all of those files. Is Redis an option for you to add while I dig deeper?

       
Linda A's avatar
Linda A
647 posts
8 years ago
Linda A's avatar Linda A

I’ll get in touch with our host to check about that, thanks. 😊

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Update: I just spun up a matching scenario to what you described, and caches are being cleared as expected when I publish a new entry, and have “Clear cache for new entries?” enabled. Can you reproduce the problem in a separate install/domain that is not proxied by Varnish, CloudFlare, or any other means?

       
Linda A's avatar
Linda A
647 posts
8 years ago
Linda A's avatar Linda A

Hrm, its complicated. We have a wiki and a forum on the server as well and taking out Varnish entirely would be a large interruption.

We’ll check if there’s any way we can test it on our secondary server, but I don’t know off the top of my head if that has Varnish too (we don’t do the setup ourselves, we have a friend who manages it).

Thank you so much, though, for looking into this.

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Yeah, don’t start pulling things off of production, for a true isolated test, a fresh environment would be needed anyway. I’m just not seeing where it would be failing. Memcached holds its values for the entire length of the expiration, but we when a cache clear event is triggered, we stop referencing the original keys, and start with a new namespace.

       
Linda A's avatar
Linda A
647 posts
8 years ago
Linda A's avatar Linda A

What is involved in a clear cache event? Does it do anything different to clear memcached compared to when it expires according to the template settings? Because as far as I can tell, the cache does clear on the 60 minute timeout.

Could it be making use of different permissions, somehow? We have had an issue in general with EE where files created by EE are owned by apache rather than our user account, and then we end up not being able to clear them manually.

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Memcached is all in-memory, so there aren’t any permissions involved, and the caching drivers all use the same core code, so respond to the same clearing events. Memcached cannot flush contents using a wildcard pattern with its keys, and could be storing on multiple servers, so when a cache clear is triggered, we spin up a new namespace and ignore the others. Those old ones will persist in memory until their expiry, but ExpressionEngine no longer references the old keys, essentially having “forgotten” them.

Can you share your memcached config? Both in your config.php file and Memcached’s config itself, please.

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.