Purge All LS Cache for a site - Using PHP?

#1
Hi,

I would like to do a Purge All of the LiteSpeed Cache for a site, that is all PHP and doesn't use a CMS of any type.
The server is ruuning cPanel if that makes any differents, I have looked at the purge by file PHP file in the misc folder.
I was wondering will the below clear all cache files for the domain name if I use this code:


PHP:
<?php
$fp = fsockopen('127.0.0.1', 80, $errno, $errstr, 2);
if (!$fp) {
    echo "$errstr ($errno)\n";
} else {
    $out = "PURGE / HTTP/1.0\r\n"
        . "Host: www.domain.com\r\n"
        . "Connection: Close\r\n\r\n";
    fwrite($fp, $out);
    while (!feof($fp)) {
        echo fgets($fp, 128);
    }
    fclose($fp);
}
?>
 
#3
Hi,

Thanks for the reply, do change PURGE / to X-LiteSpeed-Purge * ?
Or would it be more
PHP:
<?php
header("X-LiteSpeed-Purge * HTTP/1.0 Host: www.domain.com Connection: Close");
?>
Thanks
 
Last edited by a moderator:
Top