-
Notifications
You must be signed in to change notification settings - Fork 3.4k
OPcache: Add information to the Site Health -> Server #9260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 24 commits
24a96cd
b530158
231515b
2ef962d
620c687
e35fe8a
d546cb4
1ea330c
232ea64
152e81a
63f41ea
923db6f
801cbee
5ad77f9
0887bc7
3fd57b9
4675ff5
e62c774
4320d86
4a39b00
c3ef929
b8ee643
dd325c4
0dae7c5
fc5cf45
17e5a79
1e6815b
cb95231
8b1d774
6cd176b
677a434
2c7dee1
6ef53de
a282d58
4362720
8eaebf3
57dcb5a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2755,6 +2755,52 @@ public function get_test_search_engine_visibility() { | |
| return $result; | ||
| } | ||
|
|
||
| /** | ||
| * Tests if opcode cache is enabled and available. | ||
| * | ||
| * @since 7.0.0 | ||
| * | ||
| * @return array The test result. | ||
|
rollybueno marked this conversation as resolved.
Outdated
|
||
| */ | ||
| public function get_test_opcode_cache() { | ||
| $opcode_cache_enabled = false; | ||
| if ( function_exists( 'opcache_get_status' ) ) { | ||
| $status = @opcache_get_status( false ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discourage -- Warning emitted in failure case. | ||
| if ( $status && true === $status['opcache_enabled'] ) { | ||
|
westonruter marked this conversation as resolved.
|
||
| $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>', | ||
| 'https://www.php.net/manual/en/book.opcache.php', | ||
|
rollybueno marked this conversation as resolved.
Outdated
|
||
| __( 'Learn more about OPcache.' ), | ||
| /* translators: Hidden accessibility text. */ | ||
| __( '(opens in a new tab)' ) | ||
| ), | ||
| 'test' => 'opcache_cache', | ||
|
rollybueno marked this conversation as resolved.
Outdated
|
||
| ); | ||
|
|
||
| if ( ! $opcode_cache_enabled ) { | ||
| $result['status'] = 'recommended'; | ||
| $result['label'] = __( 'Opcode cache is not enabled' ); | ||
| $result['description'] .= '<p>' . __( 'Opcode cache is not enabled. Enabling this cache can significantly improve the performance of your site.' ) . '</p>'; | ||
|
rollybueno marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| return $result; | ||
| } | ||
|
||
|
|
||
| /** | ||
| * Returns a set of tests that belong to the site status page. | ||
| * | ||
|
|
@@ -2847,6 +2893,10 @@ public static function get_tests() { | |
| 'label' => __( 'Search Engine Visibility' ), | ||
| 'test' => 'search_engine_visibility', | ||
| ), | ||
| 'opcode_cache' => array( | ||
| 'label' => __( 'Opcode cache' ), | ||
| 'test' => 'opcode_cache', | ||
| ), | ||
| ), | ||
| 'async' => array( | ||
| 'dotorg_communication' => array( | ||
|
|
@@ -3415,14 +3465,14 @@ public function get_page_cache_headers() { | |
| 'x-srcache-fetch-status' => $cache_hit_callback, | ||
|
|
||
| // Generic caching proxies (Nginx, Varnish, etc.) | ||
| 'x-cache' => $cache_hit_callback, | ||
| 'x-cache-status' => $cache_hit_callback, | ||
| 'x-litespeed-cache' => $cache_hit_callback, | ||
| 'x-proxy-cache' => $cache_hit_callback, | ||
| 'via' => '', | ||
| 'x-cache' => $cache_hit_callback, | ||
| 'x-cache-status' => $cache_hit_callback, | ||
| 'x-litespeed-cache' => $cache_hit_callback, | ||
| 'x-proxy-cache' => $cache_hit_callback, | ||
| 'via' => '', | ||
|
|
||
| // Cloudflare | ||
| 'cf-cache-status' => $cache_hit_callback, | ||
| 'cf-cache-status' => $cache_hit_callback, | ||
| ); | ||
|
|
||
| /** | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.