PHP 5.5's OPcache extension is enabled on my (shared) web host, but for some reason it always reports "0 hits" in the stats. Could that be because it's not compatible with suPHP?
Or anyone have any other suggestions as to why there are 0 cache hits?
I've been told that no opcache extension is currently compatible with suPHP, sadly.
LiteSpeed's suEXEC can support opcode caching but only in 'daemon' or 'process group' modes, not in standard 'worker' mode (see their explanation here).
So even though you might be able to enable the opcache in cPanel or via INI, you don't get cache hits because the PHP process ends and the RAM is freed. Looks like I'm out of luck for the time being.
OPcache can be trivially enabled for CLI and basic GCI, but unless the PHP process persists over multiple requests, you will only see cache hits in contrived scenarios -- e.g. when the same script is compiled multiple times within the same request. (I say contrived, because such a script cannot define global namespace entities such as classes or functions because the second and subsequent compiles will fail.)
In most shared hosting configurations, the sysadmins will configure PHP as a one-shot php-cgi execution, that is the PHP image is initiated on a per-request basis within the hosted account UID. This has the advantages of simplicity and security. This also has the disadvantages of poor performance since PHP image startup overheads are incurred on a per-request basis, and since the mmap'ed SMA is discarded on image shutdown, any compiled scripts do not persist from request to request.
For OPcache to work, you need to have PHP processes that will persist over a burst of requests. Some mod_fcgid patterns do support this, but without further details of your config, I can't give you any further steer. Sorry.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With