Title: Set different Cache timeout for different endpoints
Last modified: June 20, 2025

---

# Set different Cache timeout for different endpoints

 *  Resolved [Timi Makinde](https://wordpress.org/support/users/temak/)
 * (@temak)
 * [11 months, 3 weeks ago](https://wordpress.org/support/topic/set-different-cache-timeout-for-different-endpoints/)
 * Hi,
 * Is it possible to set different Cache timeouts for different endpoints? At the
   moment, there is just one setting in the plugin to set the timeout – [https://prnt.sc/8am7yd6hir6V](https://prnt.sc/8am7yd6hir6V)
 * ![](https://wordpress.org/47b33e45-07af-498c-a494-856ba629c827)
 * Similar to registering custom endpoints using filters, can different timeouts
   be specified like that?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Richard Korthuis](https://wordpress.org/support/users/rockfire/)
 * (@rockfire)
 * [11 months, 3 weeks ago](https://wordpress.org/support/topic/set-different-cache-timeout-for-different-endpoints/#post-18520724)
 * Hi [@temak](https://wordpress.org/support/users/temak/) 
   Thank you for using 
   our plugin!Yes, there is a filter for that! You could do something like this:
 *     ```wp-block-code
       /** * Set a different cache timeout for the posts endpoint. * * @param int $timeout The timeout as set in the settings. * @param array $options An array of options, containing the current uri, the object type, the request headers and the request method. * * @return int */function wprc_set_posts_timeout( $timeout, $options ) {	/**	 * Available keys in $options are: uri, object_type, request_headers, request_method	 */	if ( 'posts' === $options['object_type'] || '/wp-json/wp/v2/posts' === $options['uri'] ) {		$timeout = MONTH_IN_SECONDS;	}	return $timeout;}add_filter( 'wp_rest_cache/timeout', 'wprc_set_posts_timeout', 10, 2 );
       ```
   
 *  Thread Starter [Timi Makinde](https://wordpress.org/support/users/temak/)
 * (@temak)
 * [11 months, 3 weeks ago](https://wordpress.org/support/topic/set-different-cache-timeout-for-different-endpoints/#post-18520727)
 * Oh perfect [@rockfire](https://wordpress.org/support/users/rockfire/) i’ll try
   that out but that’s exactly what I need from the looks of it. Great work with
   the plugin!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Set different Cache timeout for different endpoints’ is closed to new
replies.

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

 * 2 replies
 * 2 participants
 * Last reply from: [Timi Makinde](https://wordpress.org/support/users/temak/)
 * Last activity: [11 months, 3 weeks ago](https://wordpress.org/support/topic/set-different-cache-timeout-for-different-endpoints/#post-18520727)
 * Status: resolved