# searchpro/4.0.28/inc/thirdparty/plugin/CloudflarePageCache.php

BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS &amp; JavaScript, version 4.0.28. 30 lines.

- Page: https://pluginprobe.com/plugins/searchpro/4.0.28/code/inc/thirdparty/plugin/CloudflarePageCache.php
- Raw: https://pluginprobe.com/plugins/searchpro/4.0.28/raw/inc/thirdparty/plugin/CloudflarePageCache.php
- Modified: 2026-06-09T13:53:22+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/searchpro/4.0.28/code/inc/thirdparty/plugin/CloudflarePageCache.php#L10-L20`.

```php
<?php 
if (!defined('ABSPATH')) exit;

class CloudflarePageCache extends berqIntegrations {
    function __construct() {
        add_action('berqwp_flush_all_cache', [$this, 'flush_cache']);
        add_action('berqwp_stored_page_cache', [$this, 'flush_page_cache']);
        add_action('berqwp_flush_page_cache', [$this, 'flush_cache']);
    }

    function flush_cache() {
        if (class_exists('SW_CLOUDFLARE_PAGECACHE') && isset($GLOBALS['sw_cloudflare_pagecache'])) {
            $GLOBALS['sw_cloudflare_pagecache']->objects['cache_controller']->purge_all();
        }
    }

    function flush_page_cache($slug) {
        if (!class_exists('SW_CLOUDFLARE_PAGECACHE') || !isset($GLOBALS['sw_cloudflare_pagecache'])) {
            return;
        }

        if (empty($slug)) {
            $slug = '/';
        }

        $GLOBALS['sw_cloudflare_pagecache']->objects['cache_controller']->purge_url(home_url($slug));
    }
}

new CloudflarePageCache();
```
