When WP Rocket initiates a cache purge it walks through the cache directory and removes each file. If the folder contains millions of files or several gigabytes of data the removal process runs for many seconds. The PHP request exceeds the configured execution time and the web server aborts the connection, returning a 502 Bad Gateway response.
Server timeout settings, slow disk I/O, restrictive file permissions, or a second plugin that also triggers the purge can extend the operation further. The combined load pushes the request past FastCGI or reverse‑proxy limits, which also produces the 502 error.