cabrerahector / wordpress-popular-posts

WordPress Popular Posts - A highly customizable WordPress widget that displays your most popular posts.
https://wordpress.org/plugins/wordpress-popular-posts/
GNU General Public License v2.0
280 stars 83 forks source link

Data caching without in-memory storage #213

Closed EW0JY closed 5 years ago

EW0JY commented 5 years ago

Hi! Under "Data Caching" I've had "Enable Caching" and "Refresh cache every: 24 hours" selected for a long time now. As far as I can tell, there were no issues.

However, just now I've come across the performance section regarding Caching, where it says:

This feature is considered Beta as it hasn't been fully tested yet. To enable the pageviews cache:

  1. you need access to an in-memory data storage, like Redis or Memcached (check with your hosting provider);
  2. install and set up a persistent object cache plugin on your site (eg. Redis Object Cache by Till Krüss, or Memcached Object Cache by Automattic);
  3. add define('WPP_CACHE_VIEWS', true); to your site's wp-config.php file anywhere before the / That's all, stop editing! Happy blogging. / message.

After enabling the feature, WordPress Popular Posts will start storing your views data in-memory immediately. Setting WPP_CACHE_VIEWS to false (or removing the constant entirely from your wp-config.php file) will disable the feature.

I had not read that before and therefore have not done any of the steps mentioned.

Does my not following any of the steps mean that the enabled caching option actually doesn't do anything?

Thank you!

cabrerahector commented 5 years ago

Hi there!

Those instructions are related to the Pageviews Cache feature which has nothing to do with the Data Cache feature, they're two different things:

The Pageviews Cache is a new feature, it was introduced with WordPress Popular Posts 4.2.0 which is why you didn't see those instructions before.

EW0JY commented 5 years ago

Hi Hector,

sorry for the confusion, I got the distinction now.

Is there any way to make the Data Cache work with a CDN? Specifically, I'm using KeyCDN and like I said, I've set the Data Cache to 24 hours.

However, even though most of the site is already in cache on the CDN servers, there's always an fresh request to the origin server from the Popular Posts plugin. I can see that from waterfall diagrams (like gtmetrix's) and this request by WPP adds significantly to the page load time.

Is it possible to have the WPP cached data stored on the CDN?

Thanks so much!

cabrerahector commented 5 years ago

Well, that depends. WPP makes two kind of requests: data requests and asset requests (WPP's thumbnails & stylesheet). Only the latter can be cached by a CDN, database stuff can't be cached by CDNs - as far as I know at least.