App for Cloudflare® Pro

App for Cloudflare® Pro 1.9.2

Redis caching issues

lanlan

New member
Hello,

My website uses woodmart theme and has offloaded the images to Cloudflare R2, The problem is once I add or remove css through the theme settings, Some images on the website will fall back to the default local URL instead of the R2 URL. After I clear the Redis cache, all image urls return to normal.

This afternoon, I updated the theme and it had a similar problem, until I cleared the redis cache and it returned to normal.

Obviously this has something to do with Redis caching, what should I do to fix these issues?

Kind regards
Lan
 
What plugin are you using for Redis cache? It sounds like you have a cache for a cache. While it should work in theory, I don’t usually think it’s a good idea to have a cache for a cache (in your case, you have a page cache served by Redis for when the network edge cache is served via guest page caching?)

Using Redis for an object cache is always a good idea, but if you are going to use guest page caching, you may want to consider disabling other page caching mechanisms (even if to just benchmark the speed). Usually having a cache for a cache will make things slower, not faster.

That being said, the caching plugin you are using would be helpful regardless, because even if it’s not usually a great idea, you should be able to do it if you so choose.
 
Hello,

I use the Object Cache Pro plugin, It does not provide page cache.
I also installed FlyingPress(Plugins with the same functions as WP Rocket), but I have deactivate it. So only App for Cloudflare provides guest page caching.

I recorded a video so you can see the problem more intuitively.
 
Just as a test, if you disable the Redis object cache (you could probably just rename the wp-content/object-cache.php file since it "existing" is what normally has WordPress use an object cache), does everything work as expected? WordPress object caches cache all the WordPress options/settings, so it kind of looks like somehow the cached settings from the object cache might be returning incorrect data somehow. For example when the R2 media URLs are generated, certain settings are looked at to make the determination if it should be an R2 URL or not (for example if R2 is enable and an external bucket URL is set). If Redis is returning unexpected data for certain options/settings at any point, you would potentially see issues because the internal logic for things are seeing options set to something different (whatever Redis is returning for that particular option).

Just as a quick test, disabling the object cache should at least narrow it down to something with the object cache itself.
 
Yes, If I disable Redis object cache, Everything works as expected.

Maybe it has something to do with my redis configuration? because it will happen the same thing whether I use the free Redis Object Cache or the Object Cache Pro.
 
It does sound like that might be the case (something going on with the Redis server itself) if multiple object cache mechanisms are doing the same thing. Are you able to restart Redis to see if things start working as expected immediately after a restart?

If possible, check some of the settings for the Redis server (things like memory allocated to use for objects and also settings related to Redis evicting cached objects early). In *theory* something evicted from Redis' cache should still have things work because WordPress should repopulate it if it's missing... but maybe Redis is returning something different if an object was evicted vs. missing, so WordPress is interpreting that as being a valid result when it's not. This plugin (and everything else within WordPress) is going to assume that the data returned by an object cache is correct, so if Redis is returning something invalid for whatever reason, it's going to be a problem for sure.

If you have admin access to your server, is it an option to spin up Memcached and use that as an object cache as a test to see if it's something specific to Redis, and not WordPress' object cache system as a whole?
 
I tried restarting redis but it didn't work, we had to clear the redis cache to work properly.

But after I adjusted Redis's
Code:
maxmemory-policy allkeys-lru
to the default
Code:
maxmemory-policy noeviction
, it worked as expected.

I'll try Memcached tomorrow, thanks for your help.
 
I tried restarting redis but it didn't work, we had to clear the redis cache to work properly.

But after I adjusted Redis's
Code:
maxmemory-policy allkeys-lru
to the default
Code:
maxmemory-policy noeviction
, it worked as expected.

I'll try Memcached tomorrow, thanks for your help.
Hmmm... well glad it's working.

But also, even if an object cache evicts something on it's own, it *should* return data as if that object is missing, so not sure why it seems to be returning something different if it's missing vs. evicted. 🤔
 
Back
Top