Hi @grzegorzjanoszka,
Thanks for being a long-time user 🙂
I have no idea what the theme-...
and headers-...
cache keys should resemble.
The TSF cache keys start with:
_404_
*_ (taxonomy name)
archives_
author_
year_
month_
day_
unix_
h_ (homepage)
archives_
blog_
page_
post_
attach_
singular_
* (trimmed search query... I should convert this to search_(hash))
noob_ (something went wrong terribly)
And they’re under group:
the_seo_framework
You can completely disable TSF’s object caching under the Performance settings on the SEO Settings page. If these misses are still showing up, then it’s not TSF creating them.
In any case, I’m wondering if you should really worry about cache misses 😮
WordPress is a dynamic web platform, and therefore changes (thus misses) are to be expected.
-
This reply was modified 6 years, 1 month ago by Sybre Waaijer. Reason: Clarity
OK, I dug into that. If I disable object cache in TSF, I still get those queries. When I disable TSF plugin, I don’t see them.
I grepped the code and I found in wp-includes/class-wp-theme.php:
private function cache_get( $key ) {
return wp_cache_get( $key . ‘-‘ . $this->cache_hash, ‘themes’ );
}
In this file I also see:
if ( ! isset( $this->headers_sanitized ) ) {
$this->headers_sanitized = $this->cache_get( ‘headers’ );
and
$cache = $this->cache_get( ‘theme’ );
So I guess it is Worpdress core that is broken and generates those queries without never setting them correctly.
A constructor for class WP_Theme calls eventually those cache queries and then, for whatever reasons, never sets them. Well, there are lot of such unneeded calls in WP core. In the code there are lots of if-elseif-elseif-elseif-else’s and some of them have code to sets those cache variables. For whatever reason, in my setup they never get created, but are always queried.
Anyway – is it your plugin only creating objects based on WP_Theme? When I disable TSF plugin, I don’t get those cache queries, so I guess nothing else creates such object in my wordpress.
BtW, I found a solution. I just have to have the code:
add_filter( ‘wp_cache_themes_persistently’, ‘__return_true’ );
and those queries were gone.
Anyway, it is quite curious that only TSF generates objects of WP_Theme class.
Hi @grzegorzjanoszka,
I’m glad you’ve found a solution! 🙂
For future code pasting, you should use the code button at the top of the editor. Only then will the code remain as intended, without “beautified” quotation marks:
add_filter( 'wp_cache_themes_persistently', '__return_true' );
I just remembered that TSF does interact with themes, mainly checking to see if compatibility files need to be loaded, like for Genesis. That might explain the connection, but this all happens via WordPress’ API.
The cache misses can be explained with that the theme files are being updated, or that something is wrong like CDN offload hashing.
Cheers 🙂