---
title: "OPcache"
description: "OPcache is PHP's built-in bytecode accelerator that caches compiled opcode in shared memory. Learn how it works and how it speeds up any PHP website."
url: "https://nodea.io/en/glossary/opcache"
lang: "en"
updated: "2026-07-13"
---

# OPcache

> OPcache is PHP's built-in caching engine that stores the compiled bytecode (opcode) of scripts in memory, removing the need to recompile them on every request.

**OPcache** is an accelerator built into the [PHP](https://nodea.io/en/glossary/php) engine that keeps the compiled bytecode (opcode) of scripts in shared memory. As a result PHP no longer has to read, parse and compile the same source files on every request — from the second call onward the server pulls ready-made opcode straight from RAM.

## How OPcache works

By default PHP is an interpreted language: on each request it reads the .php files, translates them into intermediate opcode and only then executes them. That compilation step repeats over and over even though application code rarely changes. OPcache breaks the cycle — after the first compilation it stores the resulting opcode in memory and skips the entire parsing stage on subsequent calls.

The cache is periodically checked for file changes (based on timestamps), so PHP automatically recompiles modified scripts after a code update. In production the timestamp check is often disabled (validate\_timestamps=0) for maximum performance, with the cache cleared manually during deployment. It is worth distinguishing OPcache from data caches: [Redis](https://nodea.io/en/glossary/redis) and [Memcached](https://nodea.io/en/glossary/memcached) cache query results and sessions, whereas OPcache concerns compiled code only.

## Practical application

OPcache is one of the most effective and simplest ways to speed up a PHP application — it can cut page generation time by two or three times with virtually no code changes. The gain is especially visible in large CMS platforms and frameworks that load hundreds of files on every request.

On shared hosting and in prebuilt PHP images OPcache is usually enabled by default, often paired with [PHP-FPM](https://nodea.io/en/glossary/php-fpm). On your own VPS an administrator can tune the buffer size and file count to the scale of the application, translating directly into shorter response times and lower CPU usage.

### Do I have to enable OPcache myself?

On most hosting and standard PHP images OPcache is built in and enabled by default — just check its status in phpinfo. On your own server it is worth tuning, especially memory\_consumption and max\_accelerated\_files, so the cache can hold all your application's files. A buffer that is too small forces constant eviction and recompilation, which cancels the benefit.

## Related

- [PHP](https://nodea.io/en/glossary/php)
- [PHP-FPM](https://nodea.io/en/glossary/php-fpm)
- [Memcached](https://nodea.io/en/glossary/memcached)
- [Redis](https://nodea.io/en/glossary/redis)
- [Optimization](https://nodea.io/en/glossary/optimization)

---

Languages: [pl](https://nodea.pl/pl/slownik-pojec/opcache.md)  
Site index: [llms.txt](https://nodea.io/en/llms.txt)
