Title: Custom Cache timeout For Specific Endpoint
Last modified: July 1, 2024

---

# Custom Cache timeout For Specific Endpoint

 *  Resolved [Cris](https://wordpress.org/support/users/ctagupa/)
 * (@ctagupa)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/custom-cache-timeout-for-specific-endpoint/)
 * Is it possible to set a specific Cache timeout for a certain endpoint?
 * Like Category / Tags, example I’d like tags to set for 15 mins. then the rest
   of the endpoints to like 1 yearm is that possible?
 * Thanks!

Viewing 1 replies (of 1 total)

 *  Plugin Author [Richard Korthuis](https://wordpress.org/support/users/rockfire/)
 * (@rockfire)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/custom-cache-timeout-for-specific-endpoint/#post-17861142)
 * Hi [@ctagupa](https://wordpress.org/support/users/ctagupa/) 
   Thank you for using
   our plugin!Yes that is possible using the filter `wp_rest_cache/timeout` For 
   example 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 );
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Custom Cache timeout For Specific Endpoint’ 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/)

 * 1 reply
 * 2 participants
 * Last reply from: [Richard Korthuis](https://wordpress.org/support/users/rockfire/)
 * Last activity: [1 year, 11 months ago](https://wordpress.org/support/topic/custom-cache-timeout-for-specific-endpoint/#post-17861142)
 * Status: resolved