Title: WP_Site_Health::get_test_persistent_object_cache
Published: November 2, 2022
Last modified: February 24, 2026

---

# WP_Site_Health::get_test_persistent_object_cache(): array

## In this article

 * [Return](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_persistent_object_cache/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_persistent_object_cache/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_persistent_object_cache/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_persistent_object_cache/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_persistent_object_cache/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_persistent_object_cache/?output_format=md#wp--skip-link--target)

Tests if the site uses persistent object cache and recommends to use it if not.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_persistent_object_cache/?output_format=md#return)󠁿

 array The test result.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_persistent_object_cache/?output_format=md#source)󠁿

    ```php
    public function get_test_persistent_object_cache() {
    	/**
    	 * Filters the action URL for the persistent object cache health check.
    	 *
    	 * @since 6.1.0
    	 *
    	 * @param string $action_url Learn more link for persistent object cache health check.
    	 */
    	$action_url = apply_filters(
    		'site_status_persistent_object_cache_url',
    		/* translators: Localized Support reference. */
    		__( 'https://developer.wordpress.org/advanced-administration/performance/optimization/#persistent-object-cache' )
    	);

    	$result = array(
    		'test'        => 'persistent_object_cache',
    		'status'      => 'good',
    		'badge'       => array(
    			'label' => __( 'Performance' ),
    			'color' => 'blue',
    		),
    		'label'       => __( 'A persistent object cache is being used' ),
    		'description' => sprintf(
    			'<p>%s</p>',
    			__( 'A persistent object cache makes your site&#8217;s database more efficient, resulting in faster load times because WordPress can retrieve your site&#8217;s content and settings much more quickly.' )
    		),
    		'actions'     => sprintf(
    			'<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
    			esc_url( $action_url ),
    			__( 'Learn more about persistent object caching.' ),
    			/* translators: Hidden accessibility text. */
    			__( '(opens in a new tab)' )
    		),
    	);

    	if ( wp_using_ext_object_cache() ) {
    		return $result;
    	}

    	if ( ! $this->should_suggest_persistent_object_cache() ) {
    		$result['label'] = __( 'A persistent object cache is not required' );

    		return $result;
    	}

    	$available_services = $this->available_object_cache_services();

    	$notes = __( 'Your hosting provider can tell you if a persistent object cache can be enabled on your site.' );

    	if ( ! empty( $available_services ) ) {
    		$notes .= ' ' . sprintf(
    			/* translators: Available object caching services. */
    			__( 'Your host appears to support the following object caching services: %s.' ),
    			implode( ', ', $available_services )
    		);
    	}

    	/**
    	 * Filters the second paragraph of the health check's description
    	 * when suggesting the use of a persistent object cache.
    	 *
    	 * Hosts may want to replace the notes to recommend their preferred object caching solution.
    	 *
    	 * Plugin authors may want to append notes (not replace) on why object caching is recommended for their plugin.
    	 *
    	 * @since 6.1.0
    	 *
    	 * @param string   $notes              The notes appended to the health check description.
    	 * @param string[] $available_services The list of available persistent object cache services.
    	 */
    	$notes = apply_filters( 'site_status_persistent_object_cache_notes', $notes, $available_services );

    	$result['status']       = 'recommended';
    	$result['label']        = __( 'You should use a persistent object cache' );
    	$result['description'] .= sprintf(
    		'<p>%s</p>',
    		wp_kses(
    			$notes,
    			array(
    				'a'      => array( 'href' => true ),
    				'code'   => true,
    				'em'     => true,
    				'strong' => true,
    			)
    		)
    	);

    	return $result;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/class-wp-site-health.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/class-wp-site-health.php#L2523)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/class-wp-site-health.php#L2523-L2611)

## 󠀁[Hooks](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_persistent_object_cache/?output_format=md#hooks)󠁿

 [apply_filters( ‘site_status_persistent_object_cache_notes’, string $notes, string[] $available_services )](https://developer.wordpress.org/reference/hooks/site_status_persistent_object_cache_notes/)

Filters the second paragraph of the health check’s description when suggesting the
use of a persistent object cache.

 [apply_filters( ‘site_status_persistent_object_cache_url’, string $action_url )](https://developer.wordpress.org/reference/hooks/site_status_persistent_object_cache_url/)

Filters the action URL for the persistent object cache health check.

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_persistent_object_cache/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Site_Health::available_object_cache_services()](https://developer.wordpress.org/reference/classes/wp_site_health/available_object_cache_services/)`wp-admin/includes/class-wp-site-health.php` |

Returns a list of available persistent object cache services.

  | 
| [WP_Site_Health::should_suggest_persistent_object_cache()](https://developer.wordpress.org/reference/classes/wp_site_health/should_suggest_persistent_object_cache/)`wp-admin/includes/class-wp-site-health.php` |

Determines whether to suggest using a persistent object cache.

  | 
| [wp_kses()](https://developer.wordpress.org/reference/functions/wp_kses/)`wp-includes/kses.php` |

Filters text content and strips out disallowed HTML.

  | 
| [wp_using_ext_object_cache()](https://developer.wordpress.org/reference/functions/wp_using_ext_object_cache/)`wp-includes/load.php` |

Toggles `$_wp_using_ext_object_cache` on and off without directly touching global.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [esc_url()](https://developer.wordpress.org/reference/functions/esc_url/)`wp-includes/formatting.php` |

Checks and cleans a URL.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 3 more](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_persistent_object_cache/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_persistent_object_cache/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_persistent_object_cache/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.1.0](https://developer.wordpress.org/reference/since/6.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_site_health%2Fget_test_persistent_object_cache%2F)
before being able to contribute a note or feedback.