Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WP Query object cache #124

Open
beatricelucaci opened this issue Jul 12, 2023 · 2 comments
Open

WP Query object cache #124

beatricelucaci opened this issue Jul 12, 2023 · 2 comments

Comments

@beatricelucaci
Copy link

When I use object cache on my website (in my case, I’m on SiteGround, so I use Memcached) the plugin stops working correctly. More specifically: I reorder some posts, reload the page, and the posts are back in their original order.

As soon as I turn Memcached off, the problem is gone.

This probably happens because WP_Query caches results in object cache. And the plugin does not seem to invalidate this cache properly, see #115.

For more details on the WP_Query cache implementation (which was added in WP 6.1) see https://make.wordpress.org/core/2022/10/07/improvements-to-wp_query-performance-in-6-1/.

https://wordpress.org/support/topic/wp-query-object-cache/

@lkaisers
Copy link

lkaisers commented Nov 9, 2023

@beatricelucaci I had the same issue long time ago and now I headed back to it.

It seems that ColorlibHQ ist not really into fixing the issue, so I fixed it by myself. At least they provide two action hooks so you can invalidate the object cache manually when the order has changed by using the wp_cache_flush function from WordPress

add_action( 'scp_update_menu_order', 'wp_cache_flush' );
add_action( 'scp_update_menu_order_tags', 'wp_cache_flush' );

It seems to be too easy as a proper solution but it works for my case. If you had any more ideas in the past few months let me know :)

@wiegertschouten
Copy link
Contributor

@lkaisers great input! Based on your idea, I created PR #130 to fix this in the plugin itself. Let's hope it gets accepted, that would save me from having to add your code snippet to all websites where this problem occurs 🤞🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants