# searchpro/4.0.18/inc/thirdparty/server/Nginx.php

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

- Page: https://pluginprobe.com/plugins/searchpro/4.0.18/code/inc/thirdparty/server/Nginx.php
- Raw: https://pluginprobe.com/plugins/searchpro/4.0.18/raw/inc/thirdparty/server/Nginx.php
- Modified: 2026-05-19T04:58:28+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.18/code/inc/thirdparty/server/Nginx.php#L10-L20`.

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

class Nginx extends berqIntegrations {
    function __construct() {
        add_action('berqwp_flush_all_cache', [$this, 'flush_cache']);
        add_action('berqwp_stored_page_cache', [$this, 'flush_page_cache']);
    }
    
    function flush_cache()
    {
        $is_nginx = stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false;

        if ($is_nginx) {
            // Clear nginx cache

            // Common cache dirs
            $dirs = ['/var/run/nginx-cache', '/var/cache/nginx', '/var/lib/nginx/cache'];

            foreach ($dirs as $dir) {
                berqwp_unlink_recursive($dir);
            }

        }
    }

    function flush_page_cache($slug)
    {
        $is_nginx = stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false;

        if (!$is_nginx) {
            return;
        }

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

        berqReverseProxyCache::purge_cache(home_url($slug));
    }
}

new Nginx();
```
