lesterchan / wp-postviews

Enables you to display how many times a post/page had been viewed.
https://wordpress.org/plugins/wp-postviews/
114 stars 42 forks source link

How to use wp-postviews extention with Cache Enabler plugin? #34

Closed hunty closed 6 years ago

hunty commented 6 years ago

I installed wp-postviews on site with Cache Enabler plugin activated. Using standard, not async code provided in Readme <?php if(function_exists('the_views')) { the_views(); } ?> caused common problem with not updating current views (as I expected - this page is rendered and written to cache).
The only way for now is to clear cache manually and decrease cache lifetime. But I can see that you provided some async code using JS and LiteSpeed Cache:
jQuery.ajax({ type:"GET", url:viewsCacheL10n.admin_ajax_url, data:"postviews_id="+viewsCacheL10n.post_id+"&action=postviews", cache:!1, success:function(data) { if(data) { jQuery('#postviews_lscwp').html(data+' views'); } } }); but this code closely connected with LiteSpeed Cache plugin params. I need more universal solution, that I can use with Cache Enabler plugin. I will appreciate if you adivse me some solution or snippet.

lesterchan commented 6 years ago

I don’t use Cache Enabler plugin so I can’t help you on that. The LiteSpeed Cache code was provided to me by LiteSpeed devs, so I just included it.