Format:PHP OPcache file cache
| Magic | 4F 50 43 41 43 48 45 00 (OPCACHE plus NUL) |
|---|---|
| Extensions | .php.bin |
| License | PHP-3.01 (php/php-src) |
| On this wiki | Facts · Code · Notes · Topics |
Per-script cache files written by the PHP OPcache extension when opcache.file_cache is set (.php.bin): a header with the magic OPCACHE, a 32-byte system id and size, offset, timestamp and checksum fields, followed by the serialized persistent script.
Overview
With opcache.file_cache configured, OPcache writes one file per compiled PHP script. Recognition level only. Source: ext/opcache/zend_file_cache.c at php/php-src commit b7256eee3018 (see Fact:PHP OPcache file cache/struct/zend_file_cache_metainfo).
Path
On non-Windows systems the file is <file_cache dir>/<32-character system id>/<script path>.bin, where the script path is the full path of the PHP file (suffix .bin). On Windows an extra directory named with the 32-character accel_uname_id is inserted first. The system id (zend_system_id) hashes the PHP version and build, so a cache directory is only valid for the exact build that wrote it.
Header
zend_file_cache_metainfo: char magic[8] = "OPCACHE" (the 8th byte is the NUL), char system_id[32], size_t mem_size, size_t str_size, size_t script_offset, accel_time_t timestamp, uint32_t checksum. Field widths of size_t and accel_time_t follow the platform, so the header is 64-bit-specific on 64-bit builds. After the header come mem_size bytes (the serialized zend_persistent_script with pointers rewritten as offsets) and str_size bytes of interned strings. The checksum is Adler-32 over the mem_size bytes then the str_size bytes; it is verified on load only when file_cache_consistency_checks is on. The loader unlinks the file (unless file_cache_read_only) when the magic or the system id differ and logs 'wrong header' or 'wrong "system_id"'; a timestamp mismatch is checked when validate_timestamps is on.
Unverified: the layout of the serialized op_arrays (opcode handler numbers, literals, zend_string tables) depends on the PHP version and is not described here; start from zend_file_cache_unserialize_op_array in the same file and Zend/zend_compile.h of the matching version.
Code & repositories
- https://github.com/php/php-src @
b7256eee3018928d265830e5f523dcc848dea2b6· license: BSD-3-Clause
PHP: ext/opcache/zend_file_cache.c.
Tested on: source read, not run: read source only · checked 2026-10-19; last activity 2026-10-18
Evidence & references
- php/php-src at b7256eee3018: ext/opcache/zend_file_cache.c.