A WordPress plugin to cache post queries.
automattic / advanced-post-cache Goto Github PK
View Code? Open in Web Editor NEWAll up in your WP_Query, caching the things.
All up in your WP_Query, caching the things.
Right now, we hack our way around WP_Query to prevent it from doing the database query.
WordPress 4.6 added a new filter (https://developer.wordpress.org/reference/hooks/posts_pre_query/) that lets you hook in and skip the query by passing in the necessary post objects. This could simplify the Advanced Post Cache code quite a bit.
Hi there. Is there anyway that the repo could be updated with a release tag so that it can be installed via composer with a version number.
I have a WP_Query
that has a meta_query
like this:
$args = array(
'numberposts' => 10,
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'custom_key_123',
'compare' => 'EXISTS',
)
)
);
Then, I use add_post_meta
to add metadata to a new post - but my query is not updated.
The APC plugin clears the cache on two actions right now:
add_action( 'clean_term_cache', 'clear_advanced_post_cache' );
add_action( 'clean_post_cache', 'clear_advanced_post_cache' );
Neither of these run when we add, update or remove metadata.
Composer is a popular php dependancy manger. Many of automattic plugins already support it, such as jetpack and babble. Supporting it is simple, only requires having a composer.json file in the root of the project and for the repo not using git submodules.
It is extremely useful if you want to load plugins from github ๐
Related #2
It looks this plugin do not cache main query, and I also want cache comments on every page. How cache every query?
We are running Advanced Post Cache as an mu plugin.
We have one plugin that creates custom SQL on the posts_request
filter.
https://theeventscalendar.com/product/wordpress-events-calendar-pro/
Both plugins run at priority 10, meaning that Advanced Post Cache runs first because it is a mu plugin.
When Events Calendar runs the filter to alter the SQL statement, WP fails with a database error because of malformed SQL.
I switched the priority of posts_request
in Advanced Post Cache to 11, which resolved the issue, as it is able to capture and cache the custom SQL statement generated by the plugin.
Plugins that use posts_request
seem fairly rare, but I am wondering if the priority of that filter should be made later by default to try and capture instances where plugins want to muck with SQL statements.
Hi. I added in theme:
<?php echo get_num_queries(); ?>
But when I activate the plugin**, the number of queries increases?**
Shouldn't the number of queries be reduced? thanks
Warning: Parameter 2 to Advanced_Post_Cache::post_limits_request() expected to be a reference, value given in /usr/src/wordpress/wp-includes/class-wp-hook.php on line 298
With WordPress/wordpress-develop@7f7d616 being merged into core, this plugin should be deprecated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.