• Resolved Khalid

    (@k-max)


    is this the right way to use LiteSpeed_Cache_API?
    it worked and fresh data was showing, but the page load time increased, did this code break the whole stored cache?

    function stat_counter($online){
    LiteSpeed_Cache_API::set_ttl( 15) ;
    echo ‘

    • online: ‘ .$online. ‘
    • ‘;
      }
      // Calling function
      stat_counter($online);

      thanks for help

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

    (@qtwrk)

    Hi,

    Could you please explain what exactly you want to do or want to archive ?

    Best regards,

    Thread Starter Khalid

    (@k-max)

    i want to have the whole page cached, excluding only the hit counter.
    i used every possible method but i couldn’t make it, like the example above, once i exclude any part of the page and open it, LiteSpeed plugin serve the page from fresh code resulting in delay.
    i’m about to accept this as fact now and display the counter only for admin, making it rebuild cache each hour or so…
    thank you.

    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    OK , then I think you are more of needing the ESI block

    Please refer to this wiki and this wiki2

    Best regards,

    Thread Starter Khalid

    (@k-max)

    i try to include the counter.php file which is located in folder “include”
    <?php
    header(‘X-LiteSpeed-Cache-Control: public, max-age=120, esi=on’);
    echo ‘line 1 – cache friendly’;
    echo ‘<esi:include src=”/include/counter.php” cache-control=”no-cache”/>’;
    echo ‘line 3 – cache friendly’;
    ?>

    and i got this: line 1 – cache friendlyline 3 – cache friendly
    the file wasnt included, i try to force error by including wrong file name too, but it didnt fire error message, esi is on in settings but dosnt include files.
    🙁
    thanx for your help

    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    Did you create the htaccess with directive as shown in wiki ?

    If you use exact same code as in wiki , does it work for test ?

    But actually , that is just for you to understand the ESI, you should stick to sample wiki to use LSCWP API , instead of standalone ESI code.

    Best regards,

    Thread Starter Khalid

    (@k-max)

    <IfModule LiteSpeed>
    RewriteEngine on
    CacheLookup on
    RewriteRule PAGE_URI – [E=esi_on:1]
    RewriteRule PAGE_URI – [E=cache-control:max-age=120]
    and i also used header : header(‘X-LiteSpeed-Cache-Control: public, max-age=120, esi=on’);
    i used both methods separately as well
    anyway i may try LSCWP API later, thank you for your help
    have a nice day

    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    thanks , please keep us posted.

    Best regards,

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

The topic ‘using LiteSpeed_Cache_API in afunction’ is closed to new replies.