# How to flush the PHP OPcache

PHP's **OPcache** stores compiled PHP as bytecode in memory so it does not recompile your code on
every request. That speeds up the site, but it also means that after you change PHP files the cache
can keep serving the **old** code until it is refreshed.

## Flush it with the TurboStack CLI

Connect over [SSH](../../platform/hosts/ssh.md) and run:

```bash
tscli opcache clear
```

This resets the OPcache for the site's PHP-FPM, so the next requests recompile from your current
files.

## When you need it

- After deploying or editing PHP files **outside** the normal publish flow, when your changes do not
  show up.
- On sites tuned for production, where OPcache does not re-check file timestamps on every request
  (`validate_timestamps` off) for maximum performance - there, a flush is required to pick up new
  code.

> [!NOTE]
> Right after a flush the first requests are a little slower while PHP recompiles; this settles within
> moments. If you use OPcache **preloading** (`php_opcache_preload_script`), changing the preloaded
> code needs a PHP-FPM reload, not just a cache flush - see [Configure PHP](configure.md).

## Related

- [Configure PHP](configure.md)
- [Switch PHP version](switch-php-version.md)
- [Override PHP settings](override-php-settings.md)
- [Why is my site slow?](../../troubleshooting/site-slow.md)
- [TurboStack CLI](../../api/cli.md) - `tscli opcache clear`
