• Resolved Fibro Jedi

    (@fibrojedi)


    Hey,

    Note: I’m not being critical and I always assume “user error” (i.e. mine).

    I followed the setup, the right modules are active server-side and I have all green ticks when I enable object cache. The graph shows it’s working.

    However, pages are visually slower to load when the object cache is enabled, compared to when it is not. Nothing else was broken and there are no errors server-side, nor in error_log.

    Please could you help me understand why it could be running slower when enabled, what I might have got wrong in the set up or what else I can investigate please?

    • PHP Version: 8.2
    • Redis Module: phpredis
    • WordPress Version: 6.2

    (I’m happy to give any other non-sensitive info to help identify the cause).

    Thanks!

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Till Krüss

    (@tillkruess)

    Can you post your diagnostics from Settings > Redis?

    It can happen if either a plug-in keep flushing the cache on every request, or if Redis isn’t configured right. More on this in the plugin FAQ.

    Thread Starter Fibro Jedi

    (@fibrojedi)

    Sure!

    Status: Connected
    Client: PhpRedis (v5.3.7)
    Drop-in: Valid
    Disabled: No
    Ping: 1
    Errors: []
    PhpRedis: 5.3.7
    Relay: Not loaded
    Predis: 1.1.10
    Credis: Not loaded
    PHP Version: 8.2.5
    Plugin Version: 2.4.1
    Redis Version: 5.0.3
    Multisite: No
    Metrics: Enabled
    Metrics recorded: 0
    Filesystem: Working
    Global Prefix: <edited out>
    Blog Prefix: <edited out>
    WP_REDIS_CLIENT: "phpredis"
    WP_REDIS_HOST: "localhost"
    WP_REDIS_PORT: 6379
    WP_REDIS_DATABASE: 1
    WP_REDIS_TIMEOUT: 1
    WP_REDIS_READ_TIMEOUT: 1
    WP_REDIS_PREFIX: "fibrojedi"
    WP_CACHE_KEY_SALT: "+<@j>TRgVJKsL5:{fV^M,p}|*In(djHxM1$V_(*2 G+.hKa!(wCZZ2P-0%|+T:"
    WP_REDIS_PLUGIN_PATH: "/home/USERNAME/public_html/wp-content/plugins/redis-cache"
    Global Groups: [
        "blog-details",
        "blog-id-cache",
        "blog-lookup",
        "global-posts",
        "networks",
        "rss",
        "sites",
        "site-details",
        "site-lookup",
        "site-options",
        "site-transient",
        "users",
        "useremail",
        "userlogins",
        "usermeta",
        "user_meta",
        "userslugs",
        "redis-cache",
        "blog_meta"
    ]
    Ignored Groups: [
        "counts",
        "plugins",
        "themes",
        "theme_json"
    ]
    Unflushable Groups: []
    Groups Types: {
        "blog-details": "global",
        "blog-id-cache": "global",
        "blog-lookup": "global",
        "global-posts": "global",
        "networks": "global",
        "rss": "global",
        "sites": "global",
        "site-details": "global",
        "site-lookup": "global",
        "site-options": "global",
        "site-transient": "global",
        "users": "global",
        "useremail": "global",
        "userlogins": "global",
        "usermeta": "global",
        "user_meta": "global",
        "userslugs": "global",
        "redis-cache": "global",
        "counts": "ignored",
        "plugins": "ignored",
        "themes": "ignored",
        "blog_meta": "global",
        "theme_json": "ignored"
    }
    Drop-ins: [
        "advanced-cache.php v by ",
        "maintenance.php v by ",
        "Redis Object Cache Drop-In v2.4.1 by Till Krüss"
    ]

    To clarify the “advanced-cache.php” that’s there by Hummingbird.

    I can’t think any other plugin is flushing it on every request. The homepage gets flushed when a new page is posted or one is updated.

    If you need any other info – or can see where I messed up, let me know, please ??

    [edit] I edited out the prefix_ for security reasons and replaced my path’s username. Everything else is as generated by Settings → Redis → Diagnostics.

    • This reply was modified 1 year, 6 months ago by Fibro Jedi.
    • This reply was modified 1 year, 6 months ago by Fibro Jedi.
    Thread Starter Fibro Jedi

    (@fibrojedi)

    FYI, I have now run the code snippet (from your FAQ) that starts add_action('redis_object_cache_flush etc but neither normal use, nor triggering a flush generated an error log.

    • This reply was modified 1 year, 6 months ago by Fibro Jedi.
    Plugin Author Till Krüss

    (@tillkruess)

    I’d suggest putting it into a MU-Plugin.

    Thread Starter Fibro Jedi

    (@fibrojedi)

    I’ve done that now. Do I need to flush the cache manually to trigger it?

    Thread Starter Fibro Jedi

    (@fibrojedi)

    Well, I did a manual flush, given the code’s trigger, but no log appeared where I think it should – the root WP directory, I think.

    Plugin Author Till Krüss

    (@tillkruess)

    Hey!

    If you’re unable to set up the snippet, I’d suggest hiring a developer to assist you or using Object Cache Pro which has a widget that keeps track of cache flushes for you.

    Thread Starter Fibro Jedi

    (@fibrojedi)

    No, what I’m saying is I did set up the snippet as an MU-plugin but it doesn’t seem to make the error log.

    I created /wp-content/mu-plugins/object-cache-debug.php

    Inside that is

    <?php
    /* REDIS DEBUG: DISABLE WHEN FINISHED */
    add_action(
        'redis_object_cache_flush',
        function( $results, $delay, $selective, $salt, $execute_time ) {
            ob_start();
            echo date( 'c' ) . PHP_EOL;
            debug_print_backtrace();
            var_dump( func_get_args() );
            error_log( ABSPATH . '/redis-cache-flush.log', 3, ob_get_clean() );
        }, 10, 5
    );
    ?>

    It might be because of write permissions in root. I’ll change it to

    <code role="textbox" aria-multiline="true" aria-label="Code" class="block-editor-rich-text__editable rich-text" style="white-space: pre-wrap; min-width: 1px;" contenteditable="true">error_log( ABSPATH . '/wp-content/plugins/redis-cache/redis-cache-flush.log', 3, ob_get_clean() );

    And see if that works instead.

    Plugin Author Till Krüss

    (@tillkruess)

    Nice, and now a redis-cache-flush.log is created?

    Thread Starter Fibro Jedi

    (@fibrojedi)

    Darnit, I lost a reply I was drafting. No, but I do have a working error I can report (which shows the function is being triggered, at least)

    Failed to open stream: No such file or directory in /path-to-wp/wp-content/mu-plugins/object-cache-debug.php on line 11

    I tried creating a (writable) blank .log file and it didn’t write to that either.

    I’ve tested the same script on my offline server with the same result. The full error trace is

    [12-May-2023 13:14:05 UTC] PHP Warning:  error_log(2023-05-12T13:14:05+00:00
    #0 /path-to-wp/wp-includes/class-wp-hook.php(308): {closure}(Array, 0, NULL, NULL, 0.00031900405883789)
    #1 /path-to-wp/wp-includes/class-wp-hook.php(332): WP_Hook-&gt;apply_filters('', Array)
    #2 /path-to-wp/wp-includes/plugin.php(517): WP_Hook-&gt;do_action(Array)
    #3 /path-to-wp/wp-content/object-cache.php(1658): do_action('...', Array, 0, NULL, NULL, 0.00031900405883789)
    #4 /path-to-wp/wp-content/object-cache.php(149): WP_Object_Cache-&gt;flush()
    #5 /path-to-wp/wp-content/plugins/redis-cache/includes/class-plugin.php(875): wp_cache_flush()
    #6 /path-to-wp/wp-includes/class-wp-hook.php(308): Rhubarb\RedisCache\Plugin-&gt;do_admin_actions('')
    #7 /path-to-wp/wp-includes/class-wp-hook.php(332): WP_Hook-&gt;apply_filters('', Array)
    #8 /path-to-wp/wp-includes/plugin.php(517): WP_Hook-&gt;do_action(Array)
    #9 /path-to-wp/wp-admin/admin.php(237): do_action('...')
    #10 /path-to-wp/wp-admin/options-general.php(10): require_once('...')
    array(5) {
      [0]=&gt;
      array(1) {
        [0]=&gt;
        bool(true)
      }
      [1]=&gt;
      int(0)
      [2]=&gt;
      NULL
      [3]=&gt;
      NULL
      [4]=&gt;
      float(0.0003190040588378906)
    }
    ): Failed to open stream: No such file or directory in /path-to-wp/wp-content/mu-plugins/object-cache-debug.php on line 11

    I checked ABSPATH was being correctly assumed, and it was. So, I’m unsure why the log file isn’t being found/created.

    Plugin Author Till Krüss

    (@tillkruess)

    This seems like a permissions issue with you host (maybe). Did you try asking them for support?

    or change the log file path to wp-contents?

    Thread Starter Fibro Jedi

    (@fibrojedi)

    I just moved to a VPS so, to some degree, it’s my own responsibility. I’ll try changing the path next week. I’d like to nail this down so I can keep Redis running and running well.

    It’s turning into one of those “I’m 99% there, but the 1% is taking forever” things!

    Thanks for your patience ??

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Site Seems Slower with Object Cache’ is closed to new replies.