Add calculated prices to cache to speed up loading time

[ad_1]

I just found this solution:

In the code i saw there is a way to make your plugin use caching system, but i dont know why it does not show up in the documentation?

In my functions.php file, i added the below code and now the calculated prices are cached and served from cache:

if(!defined('WCPBC_CACHE_AJAXGEO_RESPONSE')){
  define('WCPBC_CACHE_AJAXGEO_RESPONSE', true);
}

Please confirm if my understanding is correct and update the documentation.

Best

Hi,

The plugin stores the “pricing zone” prices as a post meta, so it uses the get_post_meta and update_post_meta functions to get/set the values. These functions already use the object cache to get/set the values.

So, yes, the plugin stores values in the object cache.

The constant WCPBC_CACHE_AJAXGEO_RESPONSE is experimental, and you should not use it if you don’t know what you’re doing. If you enable this constant, the plugin will store the response of the geolocation AJAX in a transient. This could cause conflicts with discount plugins or break the AJAX geolocation feature.

Refreshing the price using “Javascript and AJAX” is a good solution if your cache plugin can’t generate a cache version by country (or you are not an avanced user), but LiteSpeed can do it, review:
https://docs.litespeedtech.com/lsws/cp/cpanel/geoip/#use-geoip-for-cache-varies

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer