Forum Replies Created

Viewing 5 replies - 16 through 20 (of 20 total)
  • Thread Starter Tofandel

    (@tofandel)

    And on line 1022 there is an undefined variable $tvers
    Line 1487 there is an undefined variable $cache_method

    Thread Starter Tofandel

    (@tofandel)

    Also completely unrelated, I was reading the source to locate the error, and there is an error in common.php

    $purge_savvii = new \Savvii\CacheFlusherPlugin();
    		if ( method_exists( $plugin, 'domainflush' ) ) {
    			$purge_savvii->domainflush();
    			return __( 'A cache purge request has been sent to <strong>Savvii</strong>', 'fast-velocity-minify' );
    		}

    $plugin in method_exists should be $purge_savvi

    Thread Starter Tofandel

    (@tofandel)

    And your answer is completely unrelated to what I explained…
    I’m saying that when the integration is enabled API calls are being made to cloudlfare on each request… And those api calls are synchronous so blocking script execution, which means that every non cached page gets an increase of 4s TTFB

    cloudflare_get_zone_id + cloudflare_clear_cache is executed twice on each page because a non cached post is being updated (eg when adding to the cart, passing an order, posting a comment), the result of the first request can easily and SHOULD BE cached, as for the cache clear it should be proxied and register a wordpress cron job to execute the api call on the next cron run, not in sync with the request or the user is subject to terrible waiting times

    Another possibility way easier to implement than cron job is to modify the function so that it is non blocking and runs only once

    
    public static function cloudflare_clear_cache($email = false, $key = false, $zoneid = false){
    	static $executed = false; //diff
    
    	if ($executed) { //diff
    		return;
    	}
    
    	if(!$email && !$key && !$zoneid){
    		if($cdn_values = get_option("WpFastestCacheCDN")){
    			$std_obj = json_decode($cdn_values);
    
    			foreach ($std_obj as $key => $value) {
    				if($value->id == "cloudflare"){
    					$email = $value->cdnurl;
    					$key = $value->originurl;
    					break;
    				}
    			}
    
    			if($email && $key){
    				$zone = self::cloudflare_get_zone_id($email, $key, false);
    
    				if($zone["success"]){
    					$zoneid = $zone["zoneid"];
    				}
    			}
    		}
    	}
    
    	if($email && $key && $zoneid){
    		$header = array("method" => "DELETE",
    					'headers' => array(
    									"X-Auth-Email" => $email,
    									"X-Auth-Key" => $key,
    									"Content-Type" => "application/json"
    									),
    					"blocking" => false, //diff
    					"body" => '{"purge_everything":true}'
    					);
    
    		wp_remote_request('https://api.cloudflare.com/client/v4/zones/'.$zoneid.'/purge_cache', $header);
    		$executed = true; //diff
    	}
    }
    

    Until this is solved, the cloudflare cache integration is unusable.

    • This reply was modified 6 years ago by Tofandel.
    • This reply was modified 6 years ago by Tofandel.
    • This reply was modified 6 years ago by Tofandel.
    Thread Starter Tofandel

    (@tofandel)

    A pull request has been submitted as well

    Thread Starter Tofandel

    (@tofandel)

    Hello,

    I’m using phpstorm as my IDE (not free but there is a 30 days free trial), the code analysis and autoformating are really good

    Thank you

Viewing 5 replies - 16 through 20 (of 20 total)