Post Pay Counter

The best way to pay authors on WordPress

  • Features
    • Addons
  • Cart
  • PRO version
  • Addons
  • Support
  • Tutorials
    • Questions and Answers
    • Developer documentation

Post Pay Counter caching features

November 18, 2019 by Stefano 2 Comments

Post Pay Counter supports caching and is compatible with WordPress caching plugins.
Post Pay Counter mostly implements caching for post stats, plugin settings, user settings and active payment criteria.

Since Post Pay Counter version 2.716 (May 2017), server side caching improves stats performance significantly.

On our tests, with several payment criteria active (words, visits, Facebook shares, comments), we manage to load around 10k posts in under 5 seconds on an average VPS with memcached. Un-cached stats may take up to 15 seconds to show up though, so the performance boost is clear. Post stats caching is active by default, and its status can be tweaked in the Miscellanea >  Performance section.


The standard caching caches stats details for each post, but actually rebuilds the stats table for every visit. Websites with massive amounts of data to handle may want to also cache the whole stats page for a given view. In other words, they may take a snapshot of a particular stats page that takes long to load, and then serve it quickly multiple times after.

This system is not based on memcached anymore, and is not automatic. Instead, it is file-based, and requires active action to cache something, since the cached files can be big (stats for one single author with 10k posts can reach up to 50MB). The caching mechanism relies on WP-CLI, and has been available since Post Pay Counter version 2.755 (November 2019).

The command is wp ppc stats and accepts several arguments, the manual of which can be retrieved with the command wp help ppc stats. Some examples of usage can be found in the next section; however, the option --cache-full needs to be appended if you want the result to be cached. Cached file are stored in the cache directory, which gets created the first time you cache something. Notice that there is no automatic deletion of cached files! This means that you need to take active action both in their creation and in their removal (even with an automatic script based on the creation date).

Make sure that the cached time range is exactly the same as the one you would like to see stats for in the stats page.

By default, cached full stats are only displayed if the _GET parameter cache-full is set. This may be overcome by using the following filter, which will ensure that if a snapshot that matches the request is found, then it will be used. This is particularly useful if you want to automate stats caching.

1
add_filter( 'ppc_cache_full_stats_always_show', function($status) { return true; } );

Examples

  1. Cache the default stats page:
    wp ppc stats --cache-full
  2. Cache the general view (i.e. all authors) of the stats page since the very beginning of time:
    wp ppc stats --cache-full --time-start=1970-01-01
  3. Cache the detailed view for author ID 1:
    wp ppc stats --cache-full --author=1
  4. Cache the detailed view for author ID 1 as seen by author ID 1:
    wp ppc stats --cache-full --author=1 --as-user=1

Cache after Analytics update is complete

One thing you may want to do is to run your custom cache process after Google Analytics data update is complete. Here is a sketch of a script you can schedule to run (with cron) after the GA update happens every day. Of course paths may need adjusting!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
 
GA_DIR=/var/www/html/wordpress/wp-content/plugins/post-pay-counter-pro/temp/ga/
 
while true; do
if [ ! "$(ls -A $GA_DIR)" ]; then
printf "No GA temp files found --> Update has finished\n\n";
 
cd /var/www/html/wordpress;
rm -f /var/www/html/wordpress/wp-content/plugins/post-pay-counter/cache/*
 
## Cache commands section
/usr/local/bin/wp --path=/var/www/html/wordpress/ ppc stats --as-user=1 --time-start=1970-01-01
## End
 
exit 0;
fi
 
echo "GA temp files found --> Retrying in one minute...";
sleep 60; #check again in 1 minute
done


 

  • Was this Helpful ?
  • Yes   No

Filed Under: Developer documentation, Questions & Answers, Tutorials Tagged With: caching, performance, wp-cli

Comments

  1. Andi Amd says

    March 3, 2017 at 12:29 pm

    I want this plugin is integrated with payment Indonesian Rupiah

    Reply
    • Stefano says

      March 3, 2017 at 4:38 pm

      Hi Andi,
      unfortunately PayPal does not (yet) support Indonesian Rupiah, so there’s not much we can do to integrate it with Post Pay Counter I am afraid 🙂

      Have a nice day,
      Stefano

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Your cart

Number of items in cart: 0

  • Your cart is empty.
  • Total: €0.00
  • Checkout

What are you looking for?

Connect on Facebook

Follow the Post Pay Counter page on Facebook to be up-to-date with discounts and latest releases!

Questions and answers

  • How do licenses work? Which one should I buy?
  • How can I use the payment features and pay through PayPal?
  • How do I set Google Analytics up and use it?
  • How do I set Google Adsense up and use it?
  • How do I set PayPal up and use it?
  • How do I use the shortcode to display stats in public?
  • Are there any known incompatibility issues?
  • Can I hide the stats box while editing a post?
  • Why posts I've never paid show up as paid?

Copyright © 2021 · Centric Theme on Genesis Framework · WordPress · Log in

This site uses cookies, as all sites on the planet do -- More info