1

I guess I've got some doubts on how "Zend Opcache" actually works, I'm wondering how am I supposed to save in cache only the files I include trough the PHP include() method? It seems that even not specifying opcache_compile_file() all files are cached, "index.php" included, that I don't want to be. In fact all variables that I assign in index are not refreshed for each session but I only see the cached version of index. Can anyone explain? Thanks in advance

2 Answers 2

1

I used to have the same problem and I came up with this solution: in the opcache configurations I set opcache.blacklist_filename to the path of an external blacklist file where I wrote the names of the classes I didn't want to be cached. See the documentation here for further details http://www.php.net/manual/en/opcache.configuration.php#ini.opcache.blacklist-filename

Sign up to request clarification or add additional context in comments.

Comments

0

Zend OpCache is only a cache for PHP's opcodes and saves the processor from having to convert source code to opcodes until it (the source code) changes. If you need userland caching for data that your script uses, use APCu. When you say your vairables are not refreshed, do you have a reverse proxy in front of your web server?

4 Comments

Nop, it can cache any files, if you include("toto.css");, toto.css will be cached! (ex. from my opcache_get_status() "/var/www/production/20140708212446/www/static/css (1 files) Filename Hits Memory Last used Created mobile_home.css 4 888B 23:00:14 08-07-2014 19:25:04 08-07-2014")
OK, but what are you gaining (if anything) by doing that?
AH, interesting. I almost never include a non-php file like that (usuaully just send it with the HTML and let browser or a reverse proxy cache it). So, opcode will cache the contents in memory so it gets loaded faster.
Yes exactly. I include CSS inline sometimes (for very small CSS files, especially in mobile environnement, is a good practice).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.