• Resolved 9itish

    (@9itish)


    Hi,

    I have a couple of doubts about the litespeed_buffer_after hook in LiteSpeed.

    What is the difference between litespeed_buffer_before and litespeed_buffer_after? They both seem to be manipulating the $content of the webpage.

    Also, do these hooks modify the Cached content or Cache the modified content. For example,

    // The original content is 'All the page content'.
    
    function remove_broken_style( $content ) {
        return str_replace( 'page', 'webpage', $content );
    }
    add_filter( 'litespeed_buffer_after', 'remove_broken_style', 0);
    
    // The original content becomes 'All the webpage content' with the hook.
    

    In the above example, what does LiteSpeed cache? Will the content cached by LiteSpeed plugin on my website be ‘All the page content’ or ‘All the webpage content’? Which version will be saved on all the QUIC.cloud CDN servers?

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support LiteSpeed Lisa

    (@lclarke)

    Hi @9itish

    I apologize for the delay in responding.

    LiteSpeed Cache is a server-level cache, and so, PHP is not invoked at all after the content has been cached. And without PHP, you can’t use litespeed_buffer_before or any other hook.

    This means that any of our API hooks are used on content that has not yet been cached.

    Specifically, litespeed_buffer_before acts on content before LSCache has manipulated it. So, before applying CDN rules, before applying CSS/JS optimizations, etc.

    litespeed_buffer_after acts on content that has had all of the necessary LSCache optimization and adjustments applied.

    To answer your questions:

    do these hooks modify the Cached content or Cache the modified content

    They modify the content that is ready to be cached, but before it has actually been cached.

    In the above example, what does LiteSpeed cache? Will the content cached by LiteSpeed plugin on my website be ‘All the page content’ or ‘All the webpage content’? Which version will be saved on all the QUIC.cloud CDN servers?

    “All the webpage content” will be saved and cached at the QUIC.cloud level.

    I hope this clarifies it somewhat. Please let us know if you have more questions.

    Thread Starter 9itish

    (@9itish)

    Thanks for the detailed answer @lclarke ??

    I cleared all my doubts. You guys have awesome support.

    Plugin Support LiteSpeed Lisa

    (@lclarke)

    Aw, thanks ?? Also, I’ve updated the docs based on your question, so thanks for asking it.

    Happy coding!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘LiteSpeed `litespeed_buffer_after` hook and Cheched content’ is closed to new replies.