1

I have just found it in cPanel, where I can set options and php.ini file. I have enabled opcache option. I am not seeing any effect.

It's a shared server, so I can't restart it. Does the server have to be restarted for it to have an effect?

1
  • My guess is that it probably doesn't. Is there some way that you could test if it is working and answer your own question? Sep 9, 2022 at 13:34

1 Answer 1

1

It turns out that there are two functions that provide information on opcache.

  • opcache_get_configuration()
  • opcache_get_status()

Using the latter, I can see the stats change as I navigate the website. So the server does not require a restart.

A sample dump

Array
(
    [opcache_enabled] => 1
    [cache_full] => 
    [restart_pending] => 
    [restart_in_progress] => 
    [memory_usage] => Array
        (
            [used_memory] => 9212208
            [free_memory] => 125005520
            [wasted_memory] => 0
            [current_wasted_percentage] => 0
        )

    [interned_strings_usage] => Array
        (
            [buffer_size] => 6291008
            [used_memory] => 317160
            [free_memory] => 5973848
            [number_of_strings] => 6738
        )

    [opcache_statistics] => Array
        (
            [num_cached_scripts] => 6
            [num_cached_keys] => 6
            [max_cached_keys] => 16229
            [hits] => 0
            [start_time] => 1662732928
            [last_restart_time] => 0
            [oom_restarts] => 0
            [hash_restarts] => 0
            [manual_restarts] => 0
            [misses] => 6
            [blacklist_misses] => 0
            [blacklist_miss_ratio] => 0
            [opcache_hit_rate] => 0
        )

    [scripts] => Array
        (
            [/home/example/public_html/lib/head.php] => Array
                (
                    [full_path] => /home/pacifi85/public_html/lib/head.php
                    [hits] => 0
                    [memory_consumption] => 3016
                    [last_used] => Sat Sep 10 00:15:29 2022
                    [last_used_timestamp] => 1662732929
                    [timestamp] => 1662506122
                )

            [/home/pacifi85/public_html/lib/common.php] => Array
                (
                    [full_path] => /home/example/public_html/lib/common.php
                    [hits] => 0
                    [memory_consumption] => 29248
                    [last_used] => Sat Sep 10 00:15:29 2022
                    [last_used_timestamp] => 1662732929
                    [timestamp] => 1662589081
                )

            [/home/example/public_html/downloads.php] => Array
                (
                    [full_path] => /home/example/public_html/downloads.php
                    [hits] => 0
                    [memory_consumption] => 3552
                    [last_used] => Sat Sep 10 00:15:29 2022
                    [last_used_timestamp] => 1662732929
                    [timestamp] => 1660393579
                )

            [/home/example/public_html/admin/info.php] => Array
                (
                    [full_path] => /home/example/public_html/admin/info.php
                    [hits] => 0
                    [memory_consumption] => 1264
                    [last_used] => Sat Sep 10 00:15:33 2022
                    [last_used_timestamp] => 1662732933
                    [timestamp] => 1662732831
                )

            [/home/example/public_html/lib/header.php] => Array
                (
                    [full_path] => /home/example/public_html/lib/header.php
                    [hits] => 0
                    [memory_consumption] => 4536
                    [last_used] => Sat Sep 10 00:15:29 2022
                    [last_used_timestamp] => 1662732929
                    [timestamp] => 1662587896
                )

            [/home/example/public_html/lib/footer.php] => Array
                (
                    [full_path] => /home/example/public_html/lib/footer.php
                    [hits] => 0
                    [memory_consumption] => 2504
                    [last_used] => Sat Sep 10 00:15:29 2022
                    [last_used_timestamp] => 1662732929
                    [timestamp] => 1662593866
                )

        )

)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.