• Resolved amirhmoradi

    (@amirhmoradi)


    Hi,

    I want to know if the calculated prices per country are stored in cache (i use litespeed cache with object cache on redis) once requested or are they calculated on each customer request?

    If there is no caching in play, please add it to avoid spending resources on calculating the same amounts on each request. this would also help improve price loading times.

    Best

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter amirhmoradi

    (@amirhmoradi)

    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

    Plugin Author Oscar Gare

    (@oscargare)

    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

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add calculated prices to cache to speed up loading time’ is closed to new replies.