nginx-helper icon indicating copy to clipboard operation
nginx-helper copied to clipboard

Purge taking too much time while editing a Post

Open thecancerus opened this issue 3 years ago • 9 comments

When editing a post with multiple tags and categories attached to it, it takes lots of time to update. Sometimes it can take more than a minute. When I investigated, I found that most of the time was taken in the purge requests ( anywhere between 500ms to 1.3seconds per request).

My Setup

WordPress 5.7, Nginx (based on WordOps), WPFC cache with PHP 7.4. Server: AWS t2.xlarge, OS ubuntu 20.04 Neingx helper plugin version 2.2.2

The site is behind Cloudflare

thecancerus avatar May 20 '21 06:05 thecancerus

@thecancerus looks like you are using WordOps for that https://community.wordops.net/ is the right place to look for support.

Since EE v4, we strongly recommend using Redis for full page cache.

Still, I will give a wild shot based on your use of WPFC cache.

You can try disabling the archive purge option (if its enabled)

Pasted_Image_20_05_21__1_16_PM

rahul286 avatar May 20 '21 07:05 rahul286

@rahul286 thanks, we were using the purge archive settings. I will also explore the Redis cache and see how it goes.

thecancerus avatar May 20 '21 10:05 thecancerus

Redis uses Lua so purging is very fast ➞ https://github.com/rtCamp/nginx-helper/blob/master/admin/class-predis-purger.php#L249-L258

You can uncheck archive checkboxes until you shift to redis-based full page cache.

rahul286 avatar May 20 '21 10:05 rahul286

We need to purge archives as well, so for now we have modified the plugin to insert the URLs in a queue instead of doing a real-time purge, then handled the purge using cron.

Checking the dev setup with Redis Cache, we already use Redis for other things, mostly we will also move to Redis cache from wpfc cache.

thecancerus avatar May 20 '21 11:05 thecancerus

I would suggest this fix. But the repository seems private, I can't commit. In my test case it speeds up Wordpress post saving from 9 seconds to 2 seconds.

--- a/admin/class-purger.php
+++ b/admin/class-purger.php
@@ -460,8 +460,12 @@ abstract class Purger {
                 * @param string $url URL to be purged.
                 */
                do_action( 'rt_nginx_helper_before_remote_purge_url', $url );
-
-               $response = wp_remote_get( $url );
+                
+                $request_args = array(
+                    'blocking' => false,
+                    'sslverify' => false
+                );
+               $response = wp_remote_get( $url, $request_args );

sashmarin avatar Jun 23 '23 12:06 sashmarin

WordPress/wordpress-develop#3022 should help with this.

AndrewKvalheim avatar Oct 17 '23 13:10 AndrewKvalheim