Created
October 30, 2020 09:18
-
-
Save fedek6/4dc1f34ba363659fab75cf72e1d6fbbb to your computer and use it in GitHub Desktop.
Working WordPress opcache preloading config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * WordPress opcache preloading. | |
| * Requires PHP >= 7.4. | |
| * | |
| * @author Konrad Fedorczyk <contact@realhe.ro> | |
| * @link https://stitcher.io/blog/preloading-in-php-74 | |
| * | |
| * @version 1.0.0 | |
| */ | |
| /** | |
| * Uwaga! Adjust your path. | |
| */ | |
| define('APP_PATH', '/home/developer/htdocs/oko/'); | |
| $preload_patterns = [ | |
| // WP native files (priority). | |
| 'wp-load.php', | |
| 'wp-includes/http.php', | |
| 'wp-includes/class-http.php', | |
| 'wp-includes/general-template.php', | |
| 'wp-includes/link-template.php', | |
| 'wp-includes/class-wp-http-response.php', | |
| 'wp-includes/class-wp-http-requests-hooks.php', | |
| 'wp-includes/class-wp-http-proxy.php', | |
| 'wp-includes/class-wp-http-requests-response.php', | |
| 'wp-includes/class-wp-http-cookie.php', | |
| 'wp-includes/class-wp-query.php', | |
| 'wp-includes/class-wp-tax-query.php', | |
| 'wp-includes/class-wp-user.php', | |
| 'wp-includes/class-wp-post.php', | |
| 'wp-includes/class-wp-roles.php', | |
| 'wp-includes/class-wp-role.php', | |
| 'wp-includes/taxonomy.php', | |
| 'wp-includes/post.php', | |
| 'wp-includes/user.php', | |
| 'wp-includes/pluggable.php', | |
| 'wp-includes/rest-api.php', | |
| 'wp-includes/kses.php', | |
| 'wp-includes/capabilities.php', | |
| 'wp-includes/comment.php', | |
| 'wp-includes/query.php', | |
| 'wp-includes/l10n.php', | |
| 'wp-includes/shortcodes.php', | |
| 'wp-includes/theme.php', | |
| 'wp-includes/post-template.php', | |
| 'wp-includes/post-thumbnail-template.php', | |
| 'wp-includes/media.php', | |
| 'wp-includes/date.php', | |
| 'wp-includes/author-template.php', | |
| // Rest WP files. | |
| "wp-includes/**/*.php", | |
| "wp-includes/**/**/*.php", | |
| "wp-includes/**/**/**/*.php", | |
| "wp-includes/**/**/**/**/*.php", | |
| ]; | |
| foreach ($preload_patterns as $pattern) { | |
| $files = glob(APP_PATH . $pattern); | |
| foreach ($files as $file) { | |
| opcache_compile_file($file); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Did you actually see any performance improvement? I tried this and it had no measurable impact