Title: using LiteSpeed_Cache_API in afunction
Last modified: February 13, 2020

---

# using LiteSpeed_Cache_API in afunction

 *  Resolved [Khalid](https://wordpress.org/support/users/k-max/)
 * (@k-max)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/using-litespeed_cache_api-in-afunction/)
 * 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](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/using-litespeed_cache_api-in-afunction/#post-12432736)
 * Hi,
 * Could you please explain what exactly you want to do or want to archive ?
 * Best regards,
 *  Thread Starter [Khalid](https://wordpress.org/support/users/k-max/)
 * (@k-max)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/using-litespeed_cache_api-in-afunction/#post-12432976)
 * 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](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/using-litespeed_cache_api-in-afunction/#post-12433018)
 * Hi,
 * OK , then I think you are more of needing the ESI block
 * Please refer to this [wiki](https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:esi_sample)
   and this [wiki2](https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:no-plugin-advanced:esi-support)
 * Best regards,
 *  Thread Starter [Khalid](https://wordpress.org/support/users/k-max/)
 * (@k-max)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/using-litespeed_cache_api-in-afunction/#post-12435289)
 * 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](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/using-litespeed_cache_api-in-afunction/#post-12436322)
 * 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](https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:esi_sample)
   to use LSCWP API , instead of standalone ESI code.
 * Best regards,
 *  Thread Starter [Khalid](https://wordpress.org/support/users/k-max/)
 * (@k-max)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/using-litespeed_cache_api-in-afunction/#post-12436877)
 * <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](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/using-litespeed_cache_api-in-afunction/#post-12436881)
 * 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.

 * ![](https://ps.w.org/litespeed-cache/assets/icon-256x256.png?rev=2554181)
 * [LiteSpeed Cache](https://wordpress.org/plugins/litespeed-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/litespeed-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/litespeed-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/litespeed-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/litespeed-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/litespeed-cache/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * Last activity: [6 years, 1 month ago](https://wordpress.org/support/topic/using-litespeed_cache_api-in-afunction/#post-12436881)
 * Status: resolved