How to flush the PHP OPcache

Flush the PHP OPcache with tscli opcache clear after deploying changed code on TurboStack, and what to expect afterwards.

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.

Before you start

  • SSH access to the host as the application's system user - see SSH access.

  • Know whether Varnish is in front of the site: a cached page looks exactly like old code, so you need to check the response headers, not just the page.

Flush it with the TurboStack CLI

Connect over SSH and run:

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.

Apply and verify

The flush takes effect immediately; nothing is restarted. Request a page you changed with a query string that is not in any cache, and confirm the new code answers:

curl -sI "https://www.example.com/?nocache=$(date +%s)" | grep -i -E "age|via"

An Age: 0 (or no Age header) tells you the answer came from PHP, not from Varnish.

If it did not work

Old code with Age above zero means Varnish is serving it - clear that cache too, see Clear the Varnish cache. Old code with Age: 0 on a site that uses preloading means the preloaded files were not refreshed: reload PHP-FPM as shown above. See Why is my site slow?, or contact support.