Skip to content
Advertisement

Is blacklist of opcache ignored when file_cache is enabled?

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.

php.ini

JavaScript

opcache_blacklist.txt

JavaScript

test.php

JavaScript

Some information from test.php

JavaScript

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_scripts and 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?

Advertisement

Answer

You are getting the expected bahavior. Basically you told php to execlude everything from caching!.

A normal blacklist file would look like:

JavaScript

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

JavaScript

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.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement