How to increase caching times

Occasionally, you may need to request more courses or bundles per API call, especially in schools with more than approximately 100 courses or bundles. Furthermore, you may want to increase the API cache to avoid API timeout issues.

For large schools, we recommend increasing the cache timeout to 1 hour, or more if you don't frequently change course content, and increasing your API filter limit to 100 (Note, greater values, such as 250, can cause errors. Therefore, we recommend using 100 as a starting point)

By default:

  • The plugin requests 25 courses or bundles per API call
  • The plugin caches course data for 5 mins (300 seconds)

Add the following code to your functions.php file or similar if you wish to increase these values. Note that we do not offer support for custom coding. We strongly recommend backing up your site before adding any custom code.

// Set custom TTL for specific Thinkific cache key for 'products'
add_filter('wooninja/thinkific/api/cache/ttl', function ($ttl, $key, $value) {
    if ($key === 'wooninja_thinkific_products_selector') {
        return 60 * 60; // 60 minutes in seconds
    }
    return $ttl;
}, 10, 3);

// Set default iterable filter for products entity e.g. Return 100 products per call
add_filter('wooninja/thinkific/api/iterable/filter', function ($filter, $entity) {
    if ($entity === 'products') {
        return ['limit' => 100];
    }
    return $filter;
}, 10, 2);

Still need help? Contact Us Contact Us