Advanced: Cache in shortcodes

Each StartApp's brand shortcodes are cached for performance reasons. Normally you won't have any issues with shortcode cache because we use a lot of information (shortcode name, attributes, content and current post ID) to build the cache key. This must guarantee the unique cache key for every pairs of shortcode attributes.

It is recommended to disable the cache while your site in developing to avoid any unnecessary issues. You can disable cache in Theme Options. Go to your Dashboard > StartApp > Theme Options > Advanced > Caching in shortcodes option.

NOTE: Disabling this option will not flush the cache. Caching will not be used.

You can do the same via the filter in your child theme or plugin. Filter should return FALSE to DISABLE cache. Here some examples.

Completely disable cache for all shortcodes (similar result if you disable the option):

add_filter( 'startapp_shortcode_is_cache', '__return_false' )

In case you want disable cache for specific shortcode, like startapp_button:

add_filter( 'startapp_shortcode_is_cache', function ( $is_cache, $shortcode ) {
   return 'startapp_button' === $shortcode ? false : true;
}, 10, 2 );

If you want disable cache for several shortcodes no need to add a filter for each shortcode:

 * Disable cache for some shortcodes
 * @param bool   $is_cache  Whether to enable or disable cache
 * @param string $shortcode Shortcode tag
 * @return bool
function startapp_child_disable_shortcodes_cache( $is_cache, $shortcode ) {
   // disable cache for this shortcodes
   $shortcodes = array(
   return ( ! in_array( $shortcode, $shortcodes, true ) );
add_filter( 'startapp_shortcode_is_cache', 'startapp_child_disable_shortcodes_cache', 10, 2 );

This will disable cache for the list of shortcodes: startapp_button, startapp_block_title and startapp_map.

Also you can change the expiration time:

add_filter( 'startapp_shortcode_cache_expiration', function ( $expiration ) {
   return 60 * 60; // 1 hour
} );

This filter should return the amount of seconds. Default value is 86400 seconds or 1 day.

You can change expiration time for particular shortcode (or a list of shortcodes). For this purposes the shortcode tag is passed as a second parameter to the callback.

 * Custom expiration time for startapp_blog and startapp_portfolio shortcode
 * @param int    $expiration
 * @param string $shortcode
 * @return int
function startapp_child_shortcode_cache_expiration( $expiration, $shortcode ) {
   $list = array(
   if ( in_array( $shortcode, $list ) ) {
      return $expiration * 10; // cache for 10 days
   return $expiration;
add_filter( 'startapp_shortcode_cache_expiration', 'startapp_child_shortcode_cache_expiration', 10, 2 );

Related articles

Advanced: How to modify shortcode mapping?

Advanced: How to modify shortcode template?