Jump to:

5537 Posts in 1737 Topics by 1223 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Run Cache Flush Command (for Varnish) on Publish

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 829 Views
  • Bam
    Avatar
    Community Member
    16 Posts

    Re: Run Cache Flush Command (for Varnish) on Publish Link to this post

    Brilliant, that did the trick:

    public function onAfterWrite() {
    if($this->ParentID) {
    $top = $this->getAncestors()->First();
    } else {
    $top = $this;
    }
    $cmd = escapeshellarg('ban.url ' . $top->Link());
    system('varnishadm -T :6082 ' . $cmd);
    return true;
    }

    Thanks again!

    829 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.