wp-rocket icon indicating copy to clipboard operation
wp-rocket copied to clipboard

Updating menu and widgets, and WP Rocket->Clear cache results in 502 timeout

Open kirstenctz opened this issue 1 year ago • 2 comments

We are running WP Rocket Version 3.16.4, WordPress Version 6.6.1 and PHP 8.2. We have set Cache Lifespan setting to 10 hours and disabled mobile caching.

Every time we attempt to update the menus or widgets, or clear WP Rocket cache via the dashboard, we get "502 Bad Gateway" after 120s or 2m.

We have identified the cause of the 502 error as a timeout occurring during the WP Rocket cache cleanup function. Specifically, when saving the menu, the cache clearing process part of the save function is taking too long due to the size of the on-disk cache, which currently stands at over 9.5 GB and contains more than 160,570 files.

If we manually clear WP Rocket cache directory, we are able to save the menus and clear WP Rocket cache via the dashboard successfully, but only momentarily. Within a few hours, WP Rocket cache directory would have grown big and we would get 502 bad gateway timeout again.

Most of our server configuration timeout limits are set at 600s.

Find attached the Site Health Info and screenshot of PHP 8.2 Slow Log showing the calls to the WP-Rocket rocket_rrmdir() and delete() functions.

If anyone assist, we would really appreciate it.

Regards

phpslowlogs site-health-info.txt

kirstenctz avatar Sep 11 '24 13:09 kirstenctz

Hello @kirstenctz I believe we'd need to have access to your website or its testing environment where we could reproduce the issue and see the structure of the filesystem. The function mentioned in the log removes recursively files and scans for the new directories.

piotrbak avatar Sep 27 '24 15:09 piotrbak

Hi @piotrbak. Thank you for responding. I am happy to give you access to our site. We have installed WP File Manager which will give you access to the filesystem. I can create admin access for you and send you credentials privately.

kirstenctz avatar Sep 30 '24 10:09 kirstenctz

We have a very similar problem to this one, so I would like to get some info is there any plan to proceed with this ticket?

In our case we can reproduce this issue by saving menu, which triggers cache cleanup. If we do a Blackfire profile to understand what is happening, we can see that rocket_clean_domain, which triggers rocket_rrmdir runs 15 - 20 seconds.

I'm adding a few screenshots from Blackfire report:

Image

Image

Here is few additional info:

  • We are using PHP 8.1
  • our website is hosted on AWS
  • Size of cache directory is around 500MB
  • We can see the problem with the most recent version of WP-Rocket 3.18.1.5

Please let me know if there is any additional information that could help. Thanks

ivanmaricic1 avatar Feb 17 '25 08:02 ivanmaricic1