
OPcache にハッシュを使用させたり、各ドメインの特定のディレクトリをターゲットにして use_pwd を無効にして、同じパッケージが何度もキャッシュされないようにする方法はありますか?
デフォルトでは、OPcacheは衝突を防ぐためにスクリプトキーに作業ディレクトリを追加します。これは、opcache.use_cwd設定ですが、PHP 設定ファイルが衝突するため、複数の Web サイトを持つサーバーでは実際には役に立ちません。
背景 同じサーバー上で複数の Symfony、Magento 2 などのアプリケーションを実行していますが、ベンダー ディレクトリにはこれらの各アプリケーションの PHP コード全体の 95% が保存されており、OPcache に多数の重複ファイルが作成されています。
答え1
はい、opcache.config で次のオプションを有効にします。
; When this directive is enabled, the OPcache appends the current working
; directory to the script key, thus eliminating possible collisions between
; files with the same name (basename). Disabling the directive improves
; performance, but may break existing applications.
opcache.use_cwd=1