Forum Replies Created

Viewing 15 replies - 16 through 30 (of 492 total)
  • Thread Starter asafm7

    (@asafm7)

    @litetim I use cron.

    But I’ve checked and, on both versions, 7.5 and 7.6, this if block is executed when using cron.

    Thread Starter asafm7

    (@asafm7)

    Thanks, @litetim.

    I’ve done some more debugging and noticed this difference in purge.cls.php inside the _add() function.

    7.5:

    if (defined('LITESPEED_CLI')) {
    // Can't send, already has output, need to save and wait for next run
    self::update_option($purge2 ? self::DB_QUEUE2 : self::DB_QUEUE, $curr_built);

    self::debug('CLI request, queue stored: ' . $curr_built);
    }

    7.6:

    if (defined('LITESPEED_CLI')) {
    self::debug('CLI request, queue stored: ' . $curr_built);
    }

    7.6 is missing this line:

    self::update_option($purge2 ? self::DB_QUEUE2 : self::DB_QUEUE, $curr_built);

    I added the missing line to 7.6 and things are working properly.

    This missing line seems to be the issue.

    What do you think?

    Thread Starter asafm7

    (@asafm7)

    @litetim, unfortunately the issue isn’t resolved.

    First, I noticed I have the same issue on another website with a similar setup.

    Then, I got a notification from Wordfence saying the purge.cls.php on the original website we discussed about doesn’t match the one in the WordPress repository for this version.

    I completely removed the plugin and reinstalled the it, and the issue is back.

    It seems that the only reason it worked is that somehow the purge.cls.php file was outdated (maybe something I’ve done while debugging).

    In GitHub, I see a lot of changes were made to this file in the latest update—maybe the issue lies there.

    Thread Starter asafm7

    (@asafm7)

    @litetim, it seems like it. I’m a bit confused. I don’t really know what fixed it. We can mark it as resolved for now.

    Thread Starter asafm7

    (@asafm7)

    @litetim, I don’t know why, but it seems to be working now. Hopefully, it will keep working. For now, thanks for your help.

    Thread Starter asafm7

    (@asafm7)

    Thanks, @litetim.

    I just checked and confirmed it didn’t purge.

    The code has been running 3 times a day for a couple of years with no issues.

    During our tastings, I switched back and forth between 7.6 and 7.5 a few times – it always works on 7.5 and doesn’t work on 7.6.

    Something most likely changed in its functionality.

    What else can we try?

    Thread Starter asafm7

    (@asafm7)

    Hi, @litetim.

    I’m not sure I understand your last message.

    I don’t see any logs in LSC Purge Logs.

    Does it mean you confirm the purge isn’t happening?

    One thing I noticed is that you added the h4l_crawl_sitemap in functions.php , while I added it in the MU plugin.

    How do you deduce that the clear is not running?

    I have automated test in my code:

    $x_litespeed_cache = wp_remote_retrieve_header($server_response, 'x-litespeed-cache');

    // Not purged
    if ($x_litespeed_cache !== 'miss') {
    wp_mail($admin_email, __FUNCTION__, '[' . __LINE__ . '] ' . $url . ' - x-litespeed-cache: ' . $x_litespeed_cache);
    }

    I also confirmed it by visiting the website and checking LiteSpeed’s HTML comment.

    Thread Starter asafm7

    (@asafm7)

    @litetim, a custom mu-plugin.

    Maybe a recent change made the hook unavailable in must-use plugins context?

    Thread Starter asafm7

    (@asafm7)

    Thanks, @litetim.

    – Is the cron running?

    Yes. I get email notifications from it, as you can see in the code I shared.

    – Does the function h4l_crawl_sitemap get executed?

    Yes.

    I enabled the debug, but nothing appears.

    Did you try litespeed_purge_all in a cron?

    Thread Starter asafm7

    (@asafm7)

    @litetim, the report ID:

    EVRXAKWD

    Thanks.

    Thread Starter asafm7

    (@asafm7)

    @litetim here is the code. It worked for a long while.

    add_action('h4l_crawl_sitemap', 'h4l_crawl_sitemap');

    function h4l_crawl_sitemap() {
    // NOTE: Bypassed with a Cloudflare cache rule
    // https://dash.cloudflare.com/c82b4dfd2f76bf63583a85bc1b852bfc/hobbies4.life/caching/cache-rules
    $server_cache_crawler_user_agent = 'ServerCacheCrawler';
    $edge_cache_crawler_user_agent = 'EdgeCacheCrawler';

    $admin_email = get_option('admin_email');

    $posts_page_id = get_option('page_for_posts');
    $posts_page_url = get_permalink($posts_page_id);

    // TODO: Create a random test instead?
    $posts_page_server_response = wp_remote_get($posts_page_url, ['user-agent' => $server_cache_crawler_user_agent]);

    $x_litespeed_cache = wp_remote_retrieve_header($posts_page_server_response, 'x-litespeed-cache');
    $cf_cache_status = wp_remote_retrieve_header($posts_page_server_response, 'cf-cache-status');

    if ($x_litespeed_cache !== 'hit' || $cf_cache_status !== 'DYNAMIC') {
    wp_mail($admin_email, __FUNCTION__, '[' . __LINE__ . '] ' . $posts_page_url . ' - x-litespeed-cache: ' . $x_litespeed_cache . '; cf-cache-status: ' . $cf_cache_status);
    }

    $sitemap_index_url = get_sitemap_url('index');

    $response = wp_remote_get($sitemap_index_url);

    if (is_wp_error($response)) {
    wp_mail($admin_email, __FUNCTION__, '[' . __LINE__ . '] ' . $sitemap_index_url . ': ' . $response->get_error_message());

    return;
    }

    $sitemap_index = simplexml_load_string(wp_remote_retrieve_body($response));

    if ($sitemap_index === false) {
    return;
    }

    do_action('litespeed_purge_all');

    foreach ($sitemap_index->sitemap as $sitemap_property) {
    $sitemap_url = (string) $sitemap_property->loc;

    $response = wp_remote_get($sitemap_url);
    $sitemap = simplexml_load_string(wp_remote_retrieve_body($response));

    foreach ($sitemap->url as $url_property) {
    $url = (string) $url_property->loc;

    $blocking = ($url === $posts_page_url) ? true : false;
    $method = ($url === $posts_page_url) ? 'GET' : 'HEAD';

    $server_response = wp_remote_get($url, ['method' => $method, 'blocking' => $blocking, 'user-agent' => $server_cache_crawler_user_agent]);

    wp_remote_get($url, ['method' => 'HEAD', 'blocking' => false, 'user-agent' => $edge_cache_crawler_user_agent]);

    if (is_wp_error($server_response)) {
    wp_mail($admin_email, __FUNCTION__, '[' . __LINE__ . '] ' . $url . ': ' . $server_response->get_error_message());
    }

    // Sanity check
    if ($url === $posts_page_url) {
    $x_litespeed_cache = wp_remote_retrieve_header($server_response, 'x-litespeed-cache');

    // Not purged
    if ($x_litespeed_cache !== 'miss') {
    wp_mail($admin_email, __FUNCTION__, '[' . __LINE__ . '] ' . $url . ' - x-litespeed-cache: ' . $x_litespeed_cache);
    } else {
    $x_litespeed_cache = wp_remote_retrieve_header(wp_remote_get($url, ['method' => 'HEAD', 'user-agent' => $server_cache_crawler_user_agent]), 'x-litespeed-cache');

    // Not cached
    if ($x_litespeed_cache !== 'hit') {
    wp_mail($admin_email, __FUNCTION__, '[' . __LINE__ . '] ' . $url . ' - x-litespeed-cache: ' . $x_litespeed_cache);
    } else {
    //$check = 'passed';
    }
    }
    }

    $system_load = sys_getloadavg();

    usleep(($system_load[0] * 1000000) / 20); // microseconds
    }
    }

    // Final random check
    $products = wc_get_products(['limit' => 1, 'orderby' => 'rand', 'status' => 'publish']);

    if (!empty($products)) {
    $random_product = $products[0];

    $url = $random_product->get_permalink();

    $edge_response = wp_remote_get($url, ['method' => 'HEAD', 'user-agent' => $edge_cache_crawler_user_agent]);
    $server_response = wp_remote_get($url, ['method' => 'HEAD', 'user-agent' => $server_cache_crawler_user_agent]);

    $cf_cache_status = wp_remote_retrieve_header($edge_response, 'cf-cache-status');
    $x_litespeed_cache = wp_remote_retrieve_header($server_response, 'x-litespeed-cache');

    if ($x_litespeed_cache !== 'hit' || $cf_cache_status !== 'HIT') {
    wp_mail($admin_email, __FUNCTION__, '[' . __LINE__ . '] ' . $url . ' - x-litespeed-cache: ' . $x_litespeed_cache . '; cf-cache-status: ' . $cf_cache_status);
    } else {
    $check = 'passed';
    }
    }

    if (function_exists('aal_insert_log')) {
    $args = [
    'action' => 'created',
    'object_name' => 'Sitemap Crawled: ' . ($check ?? 'failed'),
    'object_type' => 'Plugins'
    ];

    aal_insert_log($args);
    }
    }
    Thread Starter asafm7

    (@asafm7)

    @litetim in a cron job. Purging all cache before crawling the sitemap. Let me know if you need more information.

    Thanks again.

    Thread Starter asafm7

    (@asafm7)

    Thanks, @jamesosborne.

    It’s not an issue in the sense that it doesn’t prevent tracking. But ad blockers are more likely to block the current EU-UK GTG implementation. And, if I understand correctly, one of the main goals of GTG is to prevent ad blockers from interrupting.

    In other words, in the EU-UK, the implementation falls back to a regular non-GTG implementation, at least according to my understanding.

    Thread Starter asafm7

    (@asafm7)

    Hi, @jamesosborne.

    Is there an update by any chance?

    Thanks again for your time.

    Thread Starter asafm7

    (@asafm7)

    Hi, @maybellyne. Thanks for your reply.

    I see wpseo_titles and metadesc-home-wpseo in the wp_options table.

Viewing 15 replies - 16 through 30 (of 492 total)