Forum Replies Created

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter harrywp84

    (@harrywp84)

    Yes! As you can see it is a very strange problem.

    Don’t the full logs indicate any oddities that could be fixed?

    Thread Starter harrywp84

    (@harrywp84)

    With Flamingo active:
    x-litespeed-cache: hit before form submission
    x-litespeed-cache: hit after form submission BUT with modified date, because re-cached

    With Flamingo deactivated:
    x-litespeed-cache: hit before form submission
    x-litespeed-cache: hit after form submission
    but same date

    With Flamingo active:
    I also noticed this, I temporarily deactivated the purge of Front page, Home page, Pages, despite this, when I submit the form, Front page which coincides with Home page, is purged, while the other pages are not purged.

    Thread Starter harrywp84

    (@harrywp84)

    I use this code in mu-plugins:

    function lscwp_suppress_purge_update( $new_status, $old_status, $post ) {
    // Debug log: indicate function entry
    error_log( "[LSCache Debug] lscwp_suppress_purge_update called for post #{$post->ID}, type {$post->post_type}, status {$old_status}→{$new_status}" );

    if ( $post->post_type != 'flamingo_inbound' && $post->post_type != 'flamingo_contact' ) {
    // Debug log: post type not excluded
    error_log( "[LSCache Debug] Post type {$post->post_type} not excluded, exiting." );
    return;
    }

    // Debug log: post type is excluded
    error_log( "[LSCache Debug] Post type {$post->post_type} is excluded, starting ob_start()." );

    ob_start( function($buffer) use ($post) {
    // Debug log: inside buffer callback
    error_log( "[LSCache Debug] Inside ob_start callback for post #{$post->ID}, sending override header." );
    @header("X-LiteSpeed-Purge: nothing");
    return $buffer;
    } );

    }
    add_action( 'transition_post_status', 'lscwp_suppress_purge_update', 10, 3 );

    should block purge-all triggered by form submission because Flamingo plugin saves flamingo_inbound and flamingo_contact records in _posts. Purge-all still triggers on every submission.

    Here are all the logs capturing the last send:

    debug.log
    [28-May-2025 05:00:58 UTC] [LSCache Debug] lscwp_suppress_purge_update called for post #29575, type flamingo_contact, status new→publish
    [28-May-2025 05:00:58 UTC] [LSCache Debug] Post type flamingo_contact is excluded, starting ob_start().
    [28-May-2025 05:00:58 UTC] [LSCache Debug] lscwp_suppress_purge_update called for post #29576, type flamingo_inbound, status new→publish
    [28-May-2025 05:00:58 UTC] [LSCache Debug] Post type flamingo_inbound is excluded, starting ob_start().
    [28-May-2025 05:00:58 UTC] [LSCache Debug] Inside ob_start callback for post #29576, sending override header.
    [28-May-2025 05:00:58 UTC] [LSCache Debug] Inside ob_start callback for post #29575, sending override header.
    purge.log
    05/28/25 07:00:58.684 [XXX:6690 1 Peh] 💓 ------POST HTTP/1.1 (HTTPS) /wp-json/contact-form-7/v1/contact-forms/28989/feedback
    05/28/25 07:00:58.684 [XXX:6690 1 Peh] Query String:
    05/28/25 07:00:58.684 [XXX:6690 1 Peh] HTTP_REFERER: https://...
    05/28/25 07:00:58.684 [XXX:6690 1 Peh] X-LiteSpeed-Purge: public,30d_Po.29575,30d_URL./,30d_W.recent-posts-2,30d_FD,30d_F,30d_H,30d_PGS,30d_PGSRP,30d_REST,30d_Po.29576 => LiteSpeed\LSC->send_headers()@603 => WP_Hook->apply_filters(ARRAY)@324 => WP_Hook->do_action(ARRAY)@348 =>
    /home/xxx/public_html/wp-includes/load.php@517
    debug.log extended
    05/28/25 07:00:58.875 [XXX:6690 1 H5D] 💓 ------GET HTTP/1.1 (HTTPS) /wp-json/contact-form-7/v1/contact-forms/28989/refill
    05/28/25 07:00:58.875 [XXX:6690 1 H5D] Query String:
    05/28/25 07:00:58.875 [XXX:6690 1 H5D] HTTP_REFERER: https://...
    05/28/25 07:00:58.972 [XXX:6690 1 H5D] [Router] get_role:
    05/28/25 07:00:58.972 [XXX:6690 1 H5D] [Optm] init
    05/28/25 07:00:59.016 [XXX:6690 1 H5D] 💵 Cache_control init on
    05/28/25 07:00:59.022 [XXX:6690 1 H5D] 🔱 Rest API init disabled vary change
    05/28/25 07:00:59.042 [XXX:6690 1 H5D] [Router] get_role:
    05/28/25 07:00:59.042 [XXX:6690 1 H5D] [Router] get_role:
    05/28/25 07:00:59.043 [XXX:6690 1 H5D] 🔱 role id: failed, guest
    05/28/25 07:00:59.043 [XXX:6690 1 H5D] [Router] get_role:
    05/28/25 07:00:59.043 [XXX:6690 1 H5D] [Router] get_role:
    05/28/25 07:00:59.043 [XXX:6690 1 H5D] 💰 X-LiteSpeed-Cache-Control: public,max-age=604800
    05/28/25 07:00:59.043 [XXX:6690 1 H5D] [Router] get_role:
    05/28/25 07:00:59.043 [XXX:6690 1 H5D] 🔱 role id: failed, guest
    05/28/25 07:00:59.043 [XXX:6690 1 H5D] [Router] get_role:
    05/28/25 07:00:59.043 [XXX:6690 1 H5D] [Router] get_role:
    05/28/25 07:00:59.043 [XXX:6690 1 H5D] 💰 X-LiteSpeed-Tag: 30d_default,30d_URL./wp-json/contact-form-7/v1/contact-forms/28989/refill/,30d_REST,30d_
    05/28/25 07:00:59.043 [XXX:6690 1 H5D] [footer comment]

    <!-- Page cached by LiteSpeed Cache 7.1 on 2025-05-28 07:00:59 -->
    <!-- X-LiteSpeed-Cache-Control: public,max-age=604800 -->
    <!-- X-LiteSpeed-Tag: 30d_default,30d_URL./wp-json/contact-form-7/v1/contact-forms/28989/refill/,30d_REST,30d_ -->
    05/28/25 07:00:59.043 [XXX:6690 1 H5D] [Core] run hook litespeed_buffer_finalize
    05/28/25 07:00:59.043 [XXX:6690 1 H5D] [Optm] bypass: Not frontend HTML type
    05/28/25 07:00:59.043 [XXX:6690 1 H5D] [Core] Silence Comment due to REST/AJAX
    05/28/25 07:00:59.043 [XXX:6690 1 H5D] Response headers --- array (
    0 => 'Content-Type: application/json; charset=UTF-8',
    1 => 'X-Robots-Tag: noindex',
    2 => 'Link: <https://mysite.com/wp-json/>; rel="https://api.w.org/"',
    3 => 'X-Content-Type-Options: nosniff',
    4 => 'Access-Control-Expose-Headers: X-WP-Total, X-WP-TotalPages, Link',
    5 => 'Access-Control-Allow-Headers: Authorization, X-WP-Nonce, Content-Disposition, Content-MD5, Content-Type',
    6 => 'Allow: GET',
    7 => 'Vary: Origin',
    8 => 'X-LiteSpeed-Cache-Control: public,max-age=604800',
    9 => 'X-LiteSpeed-Tag: 30d_default,30d_URL./wp-json/contact-form-7/v1/contact-forms/28989/refill/,30d_REST,30d_',
    )
    05/28/25 07:00:59.043 [XXX:6690 1 H5D] End response
    --------------------------------------------------Duration: 169.23
    Thread Starter harrywp84

    (@harrywp84)

    Got it… so how should I proceed? Couldn’t you review the code knowing perfectly the LiteSpeed ​​Cache plugin? Kindly, I need to solve.

    Thread Starter harrywp84

    (@harrywp84)

    I don’t understand what I should do, I’m on a shared server, not on a server with full access.

    From the published debugs, what do you see, that it’s OK, but the purge-all still happens? I need a solution, is it possible that the script can’t be improved?

    Thread Starter harrywp84

    (@harrywp84)

    Here is the debug.log (2 sends):

    [27-May-2025 12:14:04 UTC] [LSCache Debug] lscwp_suppress_purge_update called for post #19698, type flamingo_contact, status publish→publish
    [27-May-2025 12:14:04 UTC] [LSCache Debug] Post type flamingo_contact is excluded, starting ob_start().
    [27-May-2025 12:14:04 UTC] [LSCache Debug] lscwp_suppress_purge_update called for post #29568, type flamingo_inbound, status new→publish
    [27-May-2025 12:14:04 UTC] [LSCache Debug] Post type flamingo_inbound is excluded, starting ob_start().
    [27-May-2025 12:14:05 UTC] [LSCache Debug] Inside ob_start callback for post #29568, sending override header.
    [27-May-2025 12:14:05 UTC] [LSCache Debug] Inside ob_start callback for post #19698, sending override header.

    [27-May-2025 12:26:32 UTC] [LSCache Debug] lscwp_suppress_purge_update called for post #29569, type flamingo_contact, status new→publish
    [27-May-2025 12:26:32 UTC] [LSCache Debug] Post type flamingo_contact is excluded, starting ob_start().
    [27-May-2025 12:26:32 UTC] [LSCache Debug] lscwp_suppress_purge_update called for post #29570, type flamingo_inbound, status new→publish
    [27-May-2025 12:26:32 UTC] [LSCache Debug] Post type flamingo_inbound is excluded, starting ob_start().
    [27-May-2025 12:26:32 UTC] [LSCache Debug] Inside ob_start callback for post #29570, sending override header.
    [27-May-2025 12:26:32 UTC] [LSCache Debug] Inside ob_start callback for post #29569, sending override header.

    Here is the debug purge (2 sends):

    05/27/25 14:14:05.353 [xxx:44916 1 RcT] 💓 ------POST HTTP/1.1 (HTTPS) /wp-json/contact-form-7/v1/contact-forms/29376/feedback
    05/27/25 14:14:05.353 [xxx:44916 1 RcT] Query String:
    05/27/25 14:14:05.353 [xxx:44916 1 RcT] HTTP_REFERER: https://xxx...
    05/27/25 14:14:05.353 [xxx:44916 1 RcT] X-LiteSpeed-Purge: public,30d_Po.19698,30d_URL./,30d_W.recent-posts-2,30d_FD,30d_F,30d_H,30d_PGS,30d_PGSRP,30d_REST,30d_Po.29568 => LiteSpeed\LSC->send_headers()@603 => WP_Hook->apply_filters(ARRAY)@324 => WP_Hook->do_action(ARRAY)@348 =>
    /home/xxx/public_html/wp-includes/load.php@517

    05/27/25 14:26:32.421 [xxx:12470 1 E7a] 💓 ------POST HTTP/1.1 (HTTPS) /wp-json/contact-form-7/v1/contact-forms/28989/feedback
    05/27/25 14:26:32.421 [xxx:12470 1 E7a] Query String:
    05/27/25 14:26:32.421 [xxx:12470 1 E7a] HTTP_REFERER: https://xxx...
    05/27/25 14:26:32.421 [xxx:12470 1 E7a] X-LiteSpeed-Purge: public,30d_Po.29569,30d_URL./,30d_W.recent-posts-2,30d_FD,30d_F,30d_H,30d_PGS,30d_PGSRP,30d_REST,30d_Po.29570 => LiteSpeed\LSC->send_headers()@603 => WP_Hook->apply_filters(ARRAY)@324 => WP_Hook->do_action(ARRAY)@348 =>
    /home/xxx/public_html/wp-includes/load.php@517

    What’s wrong? Why does purge-all always happen?

    Thread Starter harrywp84

    (@harrywp84)

    So… the code works on a staging site with Twenty Twenty-Five theme, but it doesn’t work with Divi theme. Maybe there is some problem intercepting the submissions because Divi uses a lot of Ajax?

    Thread Starter harrywp84

    (@harrywp84)

    Unfortunately with the code provided, as soon as a form is submitted, and therefore Flamingo creates 2 records, the purge-all occurs.

    Can you verify the code better, also based on the log provided?

    We need to block purge-all, we could also hook to post_author = 0 because Flamingo inserts records with post_author = 0.

    Thanks!

    Thread Starter harrywp84

    (@harrywp84)

    I need to clarify something… I don’t need to prevent the purge of the post_type flamingo_inbound and flamingo_contact when a form is submitted.

    I need to prevent the entire site from auto-purge when a form is submitted and Flamingo writes the post_type flamingo_inbound and flamingo_contact to the DB.

    Thread Starter harrywp84

    (@harrywp84)

    I inserted the following code in functions.php:

    function lscwp_suppress_purge_update( $new_status, $old_status, $post ) {
    // Debug log: indicate function entry
    error_log( "[LSCache Debug] lscwp_suppress_purge_update called for post #{$post->ID}, type {$post->post_type}, status {$old_status}→{$new_status}" );

    if ( $post->post_type != 'flamingo_inbound' && $post->post_type != 'flamingo_contact' ) {
    // Debug log: post type not excluded
    error_log( "[LSCache Debug] Post type {$post->post_type} not excluded, exiting." );
    return;
    }

    // Debug log: post type is excluded
    error_log( "[LSCache Debug] Post type {$post->post_type} is excluded, starting ob_start()." );

    ob_start( function($buffer) use ($post) {
    // Debug log: inside buffer callback
    error_log( "[LSCache Debug] Inside ob_start callback for post #{$post->ID}, sending override header." );
    @header("X-LiteSpeed-Purge: " . LSWCP_TAG_PREFIX . "_Po." . $post->ID );
    return $buffer;
    } );

    }
    add_action( 'transition_post_status', 'lscwp_suppress_purge_update', 10, 3 );

    Unfortunately the auto purge happened, debug.log gives me this:

    [20-May-2025 07:41:30 UTC] [LSCache Debug] lscwp_suppress_purge_update called for post #29503, type flamingo_contact, status new→publish
    [20-May-2025 07:41:30 UTC] [LSCache Debug] Post type flamingo_contact is excluded, starting ob_start().
    [20-May-2025 07:41:31 UTC] [LSCache Debug] lscwp_suppress_purge_update called for post #29504, type flamingo_inbound, status new→publish
    [20-May-2025 07:41:31 UTC] [LSCache Debug] Post type flamingo_inbound is excluded, starting ob_start().
    [20-May-2025 07:41:31 UTC] [LSCache Debug] Inside ob_start callback for post #29504, sending override header.
    [20-May-2025 07:41:31 UTC] [LSCache Debug] Inside ob_start callback for post #29503, sending override header.
    Thread Starter harrywp84

    (@harrywp84)

    I’m not very good at coding, the line

    if ( $post->post_type != 'flamingo_inbound' ) {
    how would it be adding flamingo_contact too?

    Thread Starter harrywp84

    (@harrywp84)

    Flamingo in addition to flamingo_inbound also writes the flamingo_contact record in pairs, so the code should also include flamingo_contact.

    I will then save this code in mu-plugins (PHP file with Plugin Name and Description, in plugin style), or is that not good?

    Thanks!

Viewing 12 replies - 1 through 12 (of 12 total)