php / php/php-src

Add whitelist support to OPcache

Open
#23,335 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Extension: opcache Feature Status: Needs Triage
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

OPcache currently supports excluding files using opcache.blacklist_filename. This works well when the number of files to exclude is small.

However, in a multi-tenant application, the opposite can be true. There may be a large number of tenant-specific files that should not be cached, while only a small set of common application files should be cached.

For example, instead of maintaining:

/var/www/tenant-a/*
/var/www/tenant-b/*
/var/www/tenant-c/*
...

it would be useful to define the files that are allowed to be cached:

opcache.whitelist_filename=/path/to/whitelist

with:

/var/www/app/src/*
/var/www/app/vendor/*

The behavior would simply be the inverse of the blacklist: when a whitelist is configured, only matching files are cached.

I think blacklist and whitelist should be mutually exclusive, with PHP-FPM failing at startup if both are configured.

This would be particularly useful for applications where the set of files that should be cached is small and well-defined, while the set of files to exclude is large or dynamic.

I'm happy to implement this and open a PR if this proposal makes sense.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining OPcache's existing opcache.blacklist_filename configuration and the PHP-FPM startup behavior described in the proposal. Determine where whitelist configuration and blacklist/whitelist exclusivity belong; done means only whitelisted files are cached and PHP-FPM fails at startup when both settings are configured.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, php
Domain
backend, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.