Cache Expiry Filters

SLSWC caches many API responses and license queries in WordPress transients. Each cache has a filter that sets how long the cached value lives. All cache expiry filters accept and return an int (seconds).

Most of these caches are only written when Cache API responses is enabled at Settings > General (off by default). The Composer packages.json cache is always used when the Composer repository is enabled.

Server Filters

HookDefaultDescriptionFile
slswc_get_product_details_cache_expiry12hProduct details cacheclass-slswc-api.php
slswc_check_license_cache_expiry12hLicense check cacheclass-slswc-api.php
slswc_check_for_update_cache_expiry12hUpdate check cacheclass-slswc-api.php
slswc_activate_license_cache_expiry12hActivation cacheclass-slswc-api.php
slswc_deactivate_license_cache_expiry12hDeactivation cacheclass-slswc-api.php
slswc_customer_licenses_cache_expiry12hCustomer licenses listclass-slswc-api.php
slswc_licenses_where_cache_expiry12hFiltered licenses queryclass-slswc-api.php
slswc_get_expiring_licenses_cache_expiry12hExpiring licensesclass-slswc-api.php
slswc_is_license_expiring_cache_expiry12hLicense expiry checkclass-slswc-api.php
slswc_total_licenses_cache_expiry12hTotal license countclass-slswc-api.php
slswc_total_activations_cache_expiry12hTotal activations count for a productclass-slswc-api.php
slswc_license_stats_cache_expiry1hLicense stats summaryclass-slswc-api.php
slswc_licenses_for_order_cache_expiry12hLicenses for an order item, and licenses for a productclass-slswc-api.php
get_licensed_customer_ids_cache_expiry12hLicensed customer IDs (note: no slswc_ prefix)class-slswc-api.php
get_licensed_customer_details_cache_expiry12hLicensed customer details (note: no slswc_ prefix)class-slswc-api.php
slswc_get_expiring_customers_cache_expiry12hCustomers with expiring licensesclass-slswc-api.php
slswc_signup_count_cache_expiry12hSignup count for a date rangeclass-slswc-api.php
slswc_renewal_count_cache_expiry12hRenewal count for a date rangeclass-slswc-api.php
slswc_get_customers_within_range_cache_expiry12hCustomer range queryclass-slswc-api.php
slswc_get_customers_at_start_cache_expiry12hCustomers at period startclass-slswc-api.php
slswc_get_customers_at_end_cache_expiry12hCustomers at period endclass-slswc-api.php
slswc_get_license_cache_expiry12hSingle license cacheclass-slswc-license.php
slswc_composer_packages_cache_expiry1hComposer packages.jsonclass-slswc-composer-repository.php

Tip: slswc_deactivate_license_cache_expiry, slswc_get_expiring_customers_cache_expiry, slswc_signup_count_cache_expiry and slswc_renewal_count_cache_expiry are built from the plugin's configurable prefix. If you change the prefix with the slswc_slug filter, these four hook names change with it. The other names are fixed.

Client Library Filters

The client library caches the local plugin and theme lists. These are documented with the other client hooks in the Hooks Reference: slswc_plugins_cache_expiry and slswc_themes_cache_expiry (default 2 hours each).

Customizing Cache Expiry

Reduce cache TTL for license checks during development, or increase it for high-traffic production sites:

// Reduce all license-related caches to 1 hour during development.
add_filter( 'slswc_check_license_cache_expiry', function ( $seconds ) {
    if ( wp_get_environment_type() === 'development' ) {
        return HOUR_IN_SECONDS;
    }
    return $seconds;
} );

// Extend Composer packages cache to 6 hours on production.
add_filter( 'slswc_composer_packages_cache_expiry', function ( $seconds ) {
    return 6 * HOUR_IN_SECONDS;
} );

Was this article helpful?