I am using php-fpm 7.4.3 on ubuntu 20.04. My blacklist of opcache doesn’t work at all. Scripts I visited are cached when file_cache is enabled. Here’s my configures.
opcache.save_comments=0 opcache.blacklist_filename="/etc/php/opcache_blacklist.txt" opcache.file_cache="/tmp/php" opcache.file_cache_fallback=0
/* /** /**.php /*.php *.php ** **.php
<pre> <?php print_r(opcache_get_status(true)); ?> </pre>
Some information from test.php
[used_memory] => 9821016 [num_cached_scripts] => 44 [num_cached_keys] => 45 [max_cached_keys] => 16229 [blacklist_misses] => 2 [scripts] => Array ( .... )
There is a strange thing: everytime I refresh the test.php,
blacklist_misses is increased by 1.
If I disable file_cache (
opcache.file_cache=) in php.ini,
num_cached_keys become 0,
blacklist_misses keeps increasing,
blacklist_miss_ratio is always 100.
PHP documentation doesn’t tell me that file_cache will affect blacklist, is this by design or a bug?
You are getting the expected bahavior. Basically you told php to execlude everything from caching!.
A normal blacklist file would look like:
So file notcachedfile.php and everything in notcachedfolder will not be cached.
A cache miss means PHP tries to retrieve data from the opcache, but that specific data is not currently in the opcache
So the reason why blacklist_misses is increased everytime you refresh your test.php file is because it’s matched by the pattern you provided in your opcache_blacklist.txt
Which means everything that is part of the / (The root directory) including your test.php file will not be in the cache, hence it shows a cache miss everytime.