WordPress.org

Ready to get started?Download WordPress

Forums

WP-PostViews
WP Post Views With W3 Total Cache ? (38 posts)

  1. ezzal
    Member
    Posted 3 years ago #

    Hi,
    Im using W3 Total Cache and the current latest version of Wp post views.
    But after installing the W3 total cache the wp post views plugin not working correctly.

    Sometimes its decreasing the post views too.
    for example :
    initial 'views' value : 220
    for the next visitor : 221
    for the next visitor : 222
    for the next visitor : 219
    for the next visitor : 218
    for the next visitor : 220
    for the next visitor : 221
    etc !

    I tried to modify the AJAX Jquery calls too.. but they are already correct.

    Can someone help me with this please ?

    in w3totalcache I've enabled (page cache,database,object cache too)

    I really like and need the post views plug-in because on my site the contents are ordered by post views (Most viewed,etc)
    Thank you.
    Dharshan

    http://wordpress.org/extend/plugins/wp-postviews/

  2. Frederick Townes
    Member
    Posted 3 years ago #

    Database caching is enabled in W3TC?

  3. ezzal
    Member
    Posted 3 years ago #

    Hi,
    Thanks for the repy.
    Yes, all database,page,object,minify caching are enabled.

    My site is : Ezzal Games

    I am tried to use the Wp-Postviews javascript call.
    example script in head:
    script type="text/javascript">jQuery.ajax({type:'GET',url:'http://www.example.com/wp-contentsss/pluginssss/wp-postviewssss/wp-postviews.php',data:'postviews_id=xxxxx',cache:false});</script>

    (which will call the PHP page using ajax method to update post views, but that is also having same problem)

    I have lot of files and some times heavy visitors on the site too..
    So disabling database caching may increase server load, right ?

    Can you recommend me any ways ? Is this possible to exclude that plugin queries from database caching ?

    Thank you for your time.

  4. Frederick Townes
    Member
    Posted 3 years ago #

    Are you using the development version?

  5. ezzal
    Member
    Posted 3 years ago #

    Yes. I use the Beta version.

  6. Frederick Townes
    Member
    Posted 3 years ago #

    If you enable the debug mode you should be able to find the queries post views is using and add the table or some other unique "stem" to the ignored query stems field on the database cache settings tab.

  7. ezzal
    Member
    Posted 3 years ago #

    Ah,ok. Thanks for the help.

  8. Frederick Townes
    Member
    Posted 3 years ago #

    You're welcome.

  9. Hiranthi
    Member
    Posted 3 years ago #

    @ezzal, did you get it working? I added "meta_key = 'views'" to the "Ignored query stems", but it's still not working (that's about the most unique thing from the query I could find).

    In another topic I read you had to set 'disk (enhanced)' to 'disk (basic)', but that didn't work either..

  10. Frederick Townes
    Member
    Posted 3 years ago #

    If your poll program uses AJAX and you're not caching database queries related to it, page caching should have no effect. If someone is doing something else, they need to explain it or I can't help.

  11. Hiranthi
    Member
    Posted 3 years ago #

    WP Postviews is not a poll plugin, it counts the views of your posts. And ofcourse it won't work if caching is 100% (iow: for everything) enabled, since that would mean not all views are counted.

    The funny thing is that the plugin doesn't count views at all since I activated W3 Total Cache, when you would expect it to count at least a few (when the page cache is getting build).

    So, I tried the solution that's mentioned in the other topic, but that doesn't work.
    I also tried disabling the cache for that specific query by adding "meta_key = 'views'" to the ignored stems, but that doesn't work either.

  12. ezzal
    Member
    Posted 3 years ago #

    I also had the same problem with my site Ezzal - Free Online Games but I got it working now.
    In the latest version of W3TC, I tried to add this code in the very top of the plugin (wp-postviews/wp-postviews.php) file. and it seems to be working so far.

    define('DONOTCACHEPAGE', true);
    define('DONOTCACHEDB', true);
    define('DONOTCACHCEOBJECT', true);

    Thank you.

  13. Frederick Townes
    Member
    Posted 3 years ago #

    Thanks @ezzal.

  14. Hiranthi
    Member
    Posted 3 years ago #

    Hmm.. I added that to the wp-postviews.php (emptied cache after that), but it still isn't working..

  15. Hiranthi
    Member
    Posted 3 years ago #

    Could these settings be the problem?

    mod_mime: Not detected
    mod_expires: Not detected
    mod_deflate / mod_gzip: Not detected
    mod_headers: Not detected
    mod_env: Not detected
    mod_setenvif: Not detected
    mod_rewrite: Not detected

  16. Hiranthi
    Member
    Posted 3 years ago #

    Hmm.. asked the hosting provider and the settings I mentioned in my last reply are set/enabled.

  17. Hiranthi
    Member
    Posted 3 years ago #

    @Frederick, if I want paid support from you for this, what will it cost me? (I know there's a Support page in the plugin admin, but I can't figure out which option I should choose).

  18. Frederick Townes
    Member
    Posted 3 years ago #

    The compatibility test isn't really relevant at the moment. I see you sent me an email so I will reply offline.

  19. jhayrocas
    Member
    Posted 3 years ago #

    I tried to add the lines of code as suggested by ezzal but it still doesn't work on my blog.

    Any update on this?

  20. Frederick Townes
    Member
    Posted 3 years ago #

    In disk enhanced mode WordPress is not loaded unless there is no cache for the page. So a stat counter plugin is not going to work properly unless you use disk basic, and even so, the same problem can occur.

  21. jhayrocas
    Member
    Posted 3 years ago #

    In disk enhanced mode WordPress is not loaded unless there is no cache for the page. So a stat counter plugin is not going to work properly unless you use disk basic, and even so, the same problem can occur.

    So this means that there's no way I can make a stat counter plugin to work properly when W3 is enabled?

  22. Frederick Townes
    Member
    Posted 3 years ago #

    It has nothing to do with W3TC. The point is *any* page caching plugin will not allow most counters to work properly if WordPress has to be loaded for the counter to work.

  23. jhayrocas
    Member
    Posted 3 years ago #

    Bummer. Thanks for clearing things up.

  24. Frederick Townes
    Member
    Posted 3 years ago #

    You're welcome.

  25. Stephen Cronin
    Member
    Posted 3 years ago #

    WP-PostViews does work when the disk enhanced page cache is enabled. It sends an Ajax request to the wp-postviews.php file. If that detects that WordPress isn't loaded, then it loads WordPress, negating the problem Frederick mentioned above.

    However, it does have a problem with the database caching. If database caching is turned on, then although WP-Postviews receives the Ajax request, it's call to update the DB does not seem to work. Well actually it does work once every 180 seconds (or whatever interval you have set for database caching).

    To get around this, you need add an ignored query stem of wp_postmeta, as WP-PostViews stores the views as a Custom Field for each post.

    Once you've done this it should be happily counting the page views you get - but...

    If the page is cached, although it will be counting views behind the scenes, it won't be able to display them. Each time the page is cleared from the cache (for example when a comment is made, or it's been cached too long), the post view count will be updates, but then the page will get cached again and it will freeze until it's next cleared.

  26. Stephen Cronin
    Member
    Posted 3 years ago #

    Okay, I've now written a plugin to resolve the problem with displaying the count. It's testing fine and I've applied to add it to the plugin directory. It should be up early next week and I'll link to it from here.

    Note, this only fixes the problem with displaying the count. You'll still need to add the database stem of wp_postmeta as mentioned above.

    For anyone interested, here's what the plugin does:

    Lester was nice enough to add a filter into WP-PostViews the_views function. The plugin uses that to wrap the count with span tags with a certain class and id (containing the post ID).

    The plugin then adds some jQuery to the footer. This finds all the counts (there may be more than one the page) and gets the post ID from each. It then sends an Ajax request to the server, which looks up the counts and sends them back to the page, which updates the appropriate count field.

    Obviously, doing this is going to take up more server resources. The server script will run once for each page load and will look up the DB to get the count (on pages with more than one post, such as the home page, it will have to look up each one). In the bigger scheme of things, you are only losing a small bit of what you've gained by using a caching plugin, but nonetheless you need to be aware it will have some impact on performance.

  27. Stephen Cronin
    Member
    Posted 3 years ago #

    The plugin is called Ajax_the_views and is now available on my web development blog or the WordPress Plugin Directory.

    I hope that helps someone - it's certainly fixed the problem for me.

  28. Frederick Townes
    Member
    Posted 3 years ago #

    Thanks Stephen.

  29. Iva
    Member
    Posted 3 years ago #

    Since I've been using WP-PostViews since 2007 and did not run into this problem prior to installing the latest version of W3 Total Cache, would I be able to import number of views from one plugin to another? I am sorry if this question is waaaay out there.

  30. iceq
    Member
    Posted 3 years ago #

    Ezzal, where did you exactly place this code?
    define('DONOTCACHEPAGE', true);
    define('DONOTCACHEDB', true);
    define('DONOTCACHCEOBJECT', true);

    I added it at the top of wp-postviews.php but that changed nothing. I added it below the first section and it ruined my theme look !

    Any solutions to this problem?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic