3

I would like to cache only specific files with OPCache... I know I can do that with opcache_compile_file but OPCache keeps caching all other files used by the server.

I also know that I can use opcache.blacklist_filename to prevent folder from being cached... But what if I want to cache only a specific directory. Can't figure how to use blacklist to cache nothing except a specific path... I would rather use a whitelist...

Anyone know how to do that ?

Sorry for my poor english.

larsAnders
  • 3,813
  • 1
  • 15
  • 19
  • Why? I can't think of any reason beyond 'a bug in opcache breaks this page' that you would *not* want opcache acceleration enabled. I assume that this is the sole reason why the blacklist exists at all. – Sammitch Apr 08 '16 at 22:29
  • @Sammitch, as the doc states: Files are usually triggered by one of the following three reasons: 1) Directories that contain auto generated code, like Smarty or ZFW cache. 2) Code that does not work well when accelerated, due to some delayed compile time evaluation. 3) Code that triggers an OPcache bug. – Yvan Apr 21 '17 at 10:26

1 Answers1

1

So far there's no easy solution for that. You have to remove all directories you don't want.

You can use the wildcards to help you a bit, but that may be a big list if you have a lot of directories.

Another option is to run PHP-FPM and have multiple pools: one would be accelerated, the other isn't (opcache disabled).

Yvan
  • 2,539
  • 26
  • 28