# searchpro/4.0.28/inc/thirdparty/hosting/LiteSpeed.php

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

- Page: https://pluginprobe.com/plugins/searchpro/4.0.28/code/inc/thirdparty/hosting/LiteSpeed.php
- Raw: https://pluginprobe.com/plugins/searchpro/4.0.28/raw/inc/thirdparty/hosting/LiteSpeed.php
- Modified: 2024-08-20T18:00:30+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/hosting/LiteSpeed.php#L10-L20`.

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

class LiteSpeed 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_page_cache']);
    }

    function flush_page_cache($slug) {

        if (empty($slug)) {
            $slug = '/';
        }
        
        if (!$this->is_litespeed()) {
            return;
        }

        @header('X-LiteSpeed-Purge: '.$slug);

        $page_url = home_url() . $slug;

        do_action( 'litespeed_purge_url', $page_url );
    }
    

    function flush_cache() {

        if (!$this->is_litespeed()) {
            return;
        }

        @header('X-LiteSpeed-Purge: *', true);

        do_action( 'litespeed_purge_all' );
    }

    function is_litespeed() {
        return isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false;
    }    

}

new LiteSpeed();
```
