• Resolved nookyyy

    (@nookyyy)


    Hey im using bricks builder on my site and would like to render some blocks with esi, as i have these blocks on nearly all my pages and dont want to purge those whenever only this block content changes. As im using polylang aswell i need to obviously have different “translations” for the blocks in those different languages.

    My current approach is to load an esi block via the litespeed_esi_url filter depending on the “template id” i provide in my custom function ( this id is the internal bricks template for that section / block ). On the frontend i am then loading that function together with the needed css + js files which seem to not load via the esi block ( i assume it only caches the pure html and does not execute all the other stuff that is loaded via that template ( see bricks builder / includes / templates.php )

    My code at this stage:

    add_action('litespeed_esi_load-best_mouse_top5_de', 'best_mouse_top5_de_esi_load');
    add_action('litespeed_esi_load-best_mouse_top5_en', 'best_mouse_top5_en_esi_load');

    function best_mouse_top5_de_esi_load($params) {
        do_action( 'litespeed_control_set_ttl', 5 );
        echo do_shortcode('[bricks_template id="' . $params['id'] . '"]');
        do_action('litespeed_debug2', '[Best Mouse Top 5 DE] - Rendered template id: ' . $params['id']);
    }

    function best_mouse_top5_en_esi_load($params){
        do_action( 'litespeed_control_set_ttl', 5 );
      echo do_shortcode('[bricks_template id="' . $params['id'] . '"]');
        do_action('litespeed_debug2', '[Best Mouse Top 5 EN] - Rendered template id: ' . $params['id']);

    }  

    function load_custom_esi($template_id) {
        $esi_status = apply_filters( 'litespeed_esi_status', false );
        if ($esi_status) {
            switch ($template_id) {
            case '4002':
                echo apply_filters('litespeed_esi_url', 'best_mouse_top5_de', 'Best Mouse Top 5 DE ESI Block', array('id' => $template_id), 'public', false, false, true, false);
                break;
            case '4698':
                echo apply_filters('litespeed_esi_url', 'best_mouse_top5_en', 'Best Mouse Top 5 EN ESI Block', array('id' => $template_id), 'public', false, false, true, false);
                break;
            }
        } else {
            echo do_shortcode('[bricks_template id="' . $template_id . '"]');
        }
    }

    On the main language (‘de’) everything works fine, but on the translated page (‘en’) the block is empty and the Cache-Control + Tags are missing aswell.

    de:

    <!-- Block cached by LiteSpeed Cache 6.5.0.2 on 2024-09-21 15:52:11 -->
    <!-- X-LiteSpeed-Cache-Control: public,max-age=5,esi=on -->
    <!-- Full varies: guest_mode:1+webp -->
    <!-- X-LiteSpeed-Tag: b79_HTTP.200,b79_ESI,b79_ESI.best_mouse_top5_de2,b79_W.template-4002,b79_ -->

    en:

    <!-- Block cached by LiteSpeed Cache 6.5.0.2 on 2024-09-21 15:39:18 -->
    <!-- X-LiteSpeed-Cache-Control: public,max-age=604800,esi=on -->
    <!-- Full varies: guest_mode:1+webp --> 
    <!-- X-LiteSpeed-Tag: b79_HTTP.200,b79_HTTP.301,b79_ -->

    Is this a bug or am i doing something wrong? – You can check the behaviour on my frontpage debug is active at this time

    Furthermore i got a question, as these 2 blocks basicly have the same content ( apart from the translations ) is it possible to just have 1 ESI block with some sort of unique identifier to distinguish between the languages. Maybe a tag like custom-esi-“ID”-“LANGPARAMTER”. If yes how would this have to be implemented? And how can i then purge that specific block with the associated unique id / tag if this is possible.

    Regards & thanks for your help

    Andre

    • This topic was modified 5 months, 3 weeks ago by nookyyy.

    The page I need help with: [log in to see the link]

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

    (@qtwrk)

    please try grab the debug log

    toolbox -> debug setting -> debug log to ON , debug level to advance, debug include URI, add lsesi and test

    then purge all , open with as https://domain.com/?test , then go to log view , share the log by https://pastebin.ubuntu.com/

    Thread Starter nookyyy

    (@nookyyy)

    Sure

    for nookyyy.com/?test : https://pastebin.ubuntu.com/p/wDQpPPMmFV/

    for nookyyy.com/en/?test: https://pastebin.ubuntu.com/p/y66kJ3mrHz/

    regards

    Plugin Support qtwrk

    (@qtwrk)

    emmm?

    on your first log

    09/21/24 22:03:40.973 [93.204.225.27:52832 1 2Q4] ?? ------GET HTTP/1.1 (HTTPS) /
    09/21/24 22:03:40.973 [93.204.225.27:52832 1 2Q4] Query String: lsesi=best_mouse_top5_de2&_control=public&esi=eyJpZCI6NDAwMn0%3D&_hash=ba6ff66dfa213b8909ac5b0747627820

    this is the ESI request , you can see by query string lsesi=best_mouse_top5_de2....

    but on your second log

    there is no such log for ESI , you did not miss anything there ?

    Thread Starter nookyyy

    (@nookyyy)

    Nope i’ve double checked – as if the esi request is “ignored” / not rendered for some reason – because i have the esi debug info in the html on the translated page like ive said in my initial post, but the full esi content is missing

    you can check here its live – https://nookyyy.com/en/?test the part is blank ( apart from my debug to console to check if esi is active which shows my function is “loading”

    Thread Starter nookyyy

    (@nookyyy)

    I did some more testing, but was unable to find the reason behind this bug. I guess it needs some deeper understanding of litespeed / esi plugin. Should i open a support ticket at litespeed directly?

    Plugin Support qtwrk

    (@qtwrk)

    yeah , please create a ticket by mail to support at litespeedtech.com

    Thread Starter nookyyy

    (@nookyyy)

    Hey just to clarify via mail or the litespeed support ticket system (we own the licence / server)

    And in case you missed my other question here once again ??

    Furthermore i got a question, as these 2 blocks basicly have the same content ( apart from the translations ) is it possible to just have 1 ESI block with some sort of unique identifier to distinguish between the languages. Maybe a tag like custom-esi-“ID”-“LANGPARAMTER”. If yes how would this have to be implemented? And how can i then purge that specific block with the associated unique id / tag if this is possible.

    regards

    Thread Starter nookyyy

    (@nookyyy)

    Hi Ticket ID is #980556

    regards

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.