• Resolved Grzegorz.Janoszka

    (@grzegorzjanoszka)


    Thank you for the great plugin!

    I have started to play with object cache on my site and I was monitoring cache misses. I noticed TSF making some strange object cache queries for object from group themes. The objects are: theme-[md5 of sth] and headers-[md5 of the same sth].

    Is it something really necessary? I have constant misses on those variables from your plugin which are driving my hit ratio down ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    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, 8 months ago by Sybre Waaijer. Reason: Clarity
    Thread Starter Grzegorz.Janoszka

    (@grzegorzjanoszka)

    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.

    Thread Starter Grzegorz.Janoszka

    (@grzegorzjanoszka)

    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.

    Plugin Author Sybre Waaijer

    (@cybr)

    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 ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Strange queries to the cache’ is closed to new replies.