• Resolved pepe80

    (@pepe80)


    How to achieve this behavior of LiteSpeed plugin:

    When post_type=”my_custom_post” is updated then purge cache only for pages:
    – mysite.com/
    – mysite.com/site1
    – mysite.com/site2

    I guess that I will not find such options in the panel, but can I code it somehow, e.g. using hooks?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support qtwrk

    (@qtwrk)

    emmm , you can check our document about purge hook here: https://docs.litespeedtech.com/lscache/lscwp/api/#purge

    a quick idea for your code

    function lscwp_suppress_purge_update( $new_status, $old_status, $post ) {
        
    if ( $new_status != 'publish' && $old_status != 'publish' ) {
    return;
    }
    # you can add post type check here to return if not your custom post type
    
    
    ob_start( function($buffer) use ($post) {
    @header("X-LiteSpeed-Purge: " . LSWCP_TAG_PREFIX . "_Po." . $post->ID );
    return $buffer;
    } );
    # then suppress the plugin generated purge tag and override it with your own purge call to purge specific pages you want to purge
    }
    
    add_action( 'transition_post_status', 'lscwp_suppress_purge_update', 10, 3 );
    Thread Starter pepe80

    (@pepe80)

    @qtwrk thanks for the hint. I’m already using this code for another problem (https://www.ads-software.com/support/topic/flamingo-plugin-and-home-page-cache) so I can adapt it easily ??
    Do you have an idea why such a header does not purge the page cache?

    $some_page_id = 902;
    @header("X-LiteSpeed-Purge: " . LSWCP_TAG_PREFIX . "_Po." . $some_page_id); // X-LiteSpeed-Purge: 805_Po.902

    Only entering the address works:

    $some_page_url = '/some-page/';
    @header("X-LiteSpeed-Purge: " . $some_page_url); // X-LiteSpeed-Purge: /some-page/
    • This reply was modified 1 year, 5 months ago by pepe80.
    Plugin Support qtwrk

    (@qtwrk)

    do you see that post id 902 page , contains PREFIX_Po.902 tag ?

    you can verify it by HTTP response header or HTML source code comment with debug setting ON

    Thread Starter pepe80

    (@pepe80)

    I see something like this:

    8051_HTTP.200,8051_page,8051_URL./some-page/,8051_Po.902,8051_PGS,8051_

    Why does the LSWCP_TAG_PREFIX return “805” instead of “8051”? Where does this number even come from?

    Plugin Support qtwrk

    (@qtwrk)

    now that is weird

    if you var_dump the LSWCP_TAG_PREFIX directly , what does it show ?

    it’s calculated and defined here https://github.com/litespeedtech/lscache_wp/blob/ce40aeeeeeae579e0f98d4fe0dbb2f8ad9fb4af5/litespeed-cache.php#L108

    Thread Starter pepe80

    (@pepe80)

    var_dump(LSWCP_TAG_PREFIX); // "805" instead of "8051"

    Before I dive into the code and try to find the cause, can you please write me why in the test environment I see such a tag in the header:

    LSWCP_TAG_PREFIX_URL./some-page/

    While in the production environment such:

    LSWCP_TAG_PREFIX_URL.f3e2bdf4db6fc922dd62344f322ff29a
    Plugin Support qtwrk

    (@qtwrk)

    did you enable something like UCSS/CCSS ?

    please use debug log , to see what was going on

    Thread Starter pepe80

    (@pepe80)

    Yes, I am using UCSS/CCSS on a production environment. Can I force tags with a readable URL somehow?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Purge cache only for selected pages’ is closed to new replies.