Purge All LS Cache for a site - Using PHP?

Discussion in 'LiteSpeed Cache General' started by GazCBG, Mar 7, 2018.

  1. GazCBG

    GazCBG Member

    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$errstr2);
    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($fp128);
        }
        
    fclose($fp);
    }
    ?>
     
  2. NiteWave

    NiteWave Administrator

    Last edited by a moderator: Mar 9, 2018
  3. GazCBG

    GazCBG Member

    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: Mar 12, 2018
  4. NiteWave

    NiteWave Administrator

    should be
    PHP:
    <?php
    header
    ("X-LiteSpeed-Purge: *");
    ?>
     
    Last edited by a moderator: Mar 12, 2018
  5. Did you get this working? Could you share your full script?
    Thanks
     

Share This Page