Title: WP_Site_Health::get_test_opcode_cache
Published: May 20, 2026

---

# WP_Site_Health::get_test_opcode_cache(): array<string,

## In this article

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

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

Tests if opcode cache is enabled and available.

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

 array<string, `string|array`<string, string>> The test result.

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

    ```php
    public function get_test_opcode_cache(): array {
    	$opcode_cache_enabled = false;
    	if ( function_exists( 'opcache_get_status' ) ) {
    		$status = @opcache_get_status( false ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Warning emitted in failure case.
    		if ( $status && true === $status['opcache_enabled'] ) {
    			$opcode_cache_enabled = true;
    		}
    	}

    	$result = array(
    		'label'       => __( 'Opcode cache is enabled' ),
    		'status'      => 'good',
    		'badge'       => array(
    			'label' => __( 'Performance' ),
    			'color' => 'blue',
    		),
    		'description' => sprintf(
    			'<p>%s</p>',
    			__( 'Opcode cache improves PHP performance by storing precompiled script bytecode in memory, reducing the need for PHP to load and parse scripts on each request.' )
    		),
    		'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( 'https://www.php.net/manual/en/book.opcache.php' ),
    			__( 'Learn more about OPcache.' ),
    			/* translators: Hidden accessibility text. */
    			__( '(opens in a new tab)' )
    		),
    		'test'        => 'opcode_cache',
    	);

    	if ( ! $opcode_cache_enabled ) {
    		$result['status']       = 'recommended';
    		$result['label']        = __( 'Opcode cache is not enabled' );
    		$result['description'] .= '<p>' . __( 'Enabling this cache can significantly improve the performance of your site.' ) . '</p>';
    	}

    	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/7.0/src/wp-admin/includes/class-wp-site-health.php#L2801)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-admin/includes/class-wp-site-health.php#L2801-L2838)

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

| Uses | Description | 
| [__()](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.

  |

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

| Version | Description | 
| [7.0.0](https://developer.wordpress.org/reference/since/7.0.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_opcode_cache%2F)
before being able to contribute a note or feedback.