Title: Variable cache timing
Last modified: June 25, 2020

---

# Variable cache timing

 *  Resolved [jmvandeel](https://wordpress.org/support/users/jmvandeel/)
 * (@jmvandeel)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/variable-cache-timing/)
 * Hi,
 * We are using this plugin as a church to show every Sunday morning a live stream
   on our website. And when no live stream is up, we show the playlist.
 * Since our Live stream is always live on Sunday morning, I would like to explore
   a way to set the caching timer variable.
    When it is Sunday morning, check often
   when a live stream is available. but any other day in the week, just check once
   or twice a day and serve the playlist from cache.
 * All this to reduce the API calls…
 * Any suggestion how to build this?
 * Can I use the filter my_ytl_custom_timeout’ in functions.php that you propose
   to achieve this?
 *     ```
       add_filter( 'wp_youtube_live_transient_timeout', 'my_ytl_custom_timeout' );
       function my_ytl_custom_timeout( $message ) {
   
           $now = new DateTime();
           $begin = new DateTime('8:00');
           $end = new DateTime('13:00');
   
           if(date('D') == 'Sun' && $now >= $begin && $now <= $end) {  
               return '15';
           }
           return '1500';
       }
       ```
   
    -  This topic was modified 5 years, 11 months ago by [jmvandeel](https://wordpress.org/support/users/jmvandeel/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fvariable-cache-timing%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 1 replies (of 1 total)

 *  Plugin Author [macbookandrew](https://wordpress.org/support/users/macbookandrew/)
 * (@macbookandrew)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/variable-cache-timing/#post-13092754)
 * Hi [@jmvandeel](https://wordpress.org/support/users/jmvandeel/),
 * I didn’t test your code, but that looks like exactly the approach I would recommend.

Viewing 1 replies (of 1 total)

The topic ‘Variable cache timing’ is closed to new replies.

 * ![](https://ps.w.org/wp-youtube-live/assets/icon-256x256.png?rev=2711798)
 * [WP YouTube Live](https://wordpress.org/plugins/wp-youtube-live/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-youtube-live/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-youtube-live/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-youtube-live/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-youtube-live/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-youtube-live/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [macbookandrew](https://wordpress.org/support/users/macbookandrew/)
 * Last activity: [5 years, 10 months ago](https://wordpress.org/support/topic/variable-cache-timing/#post-13092754)
 * Status: resolved