• Resolved greencode

    (@greencode)


    I have LiteSpeed Cache installed but with that installed and I use

    <?php echo 'Views '.wpp_get_views( $post->ID ); ?>

    on single posts to get a live view of the number of views. However, it doesn’t update due to the caching and only updates once the cache expires (every 24 hours).

    I have the following in the ESI Nonce list of LiteSpeed which should then exclude these from caching

    stats_nonce
    subscribe_nonce
    wp_rest
    wpp-*
    wpp_*

    But that doesn’t work.

    Any ideas or help would be very much appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @greencode,

    The real issue here is that your code is rendering text on page (the views count), and said text is being cached along with the entire page by LiteSpeed’s page cache ??

    If you want to prevent LiteSpeed (or any other page caching solution) from caching specific content, in this case your page/post views count, you’ll need to use AJAX to load said content dynamically.

    Thread Starter greencode

    (@greencode)

    Thanks for replying. I do have the “Ajaxify widget” setting enabled which I thought may resolve the issue. It didn’t.

    Plugin Author Hector Cabrera

    (@hcabrera)

    It won’t because “Ajaxify widget” only applies to the WordPress Popular Posts widget / block. Hence the “Ajaxify widget” text.

    You’ll need to implement your own AJAX function to prevent LiteSpeed from caching your views count on single.php. Have a look at the link I shared above, it should get you on the right track.

    Thread Starter greencode

    (@greencode)

    Thanks for this. A little beyond my developing knowledge so will have to look around for another solution.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Litespeed Cache Issue’ is closed to new replies.