elfzig

How would I perform a CLI action (here: purge Varnish cache) on comment publishing?

Vote 0 Votes

Hey there,

after a few years of using, modifying and hacking MT I've come to a point where I just don't how to achieve something. (If you don't know about Varnish, but know how to do some (CLI) action on comment publishing, you're welcome to read on, too :))

Primer: Currently, I use Intense Debate for commenting. I use it because it's being loaded dynamically. This allows me to have my blog extremely well cached using Varnish (nginx + Varnish + Movable Type Static Publishing = speeds beyond of crazy). But I'd love to get rid od it (privacy concerns etc.).

Now, I'm still more than comfortable with first page loading times if a page is uncached, and this is why I really want to use the internal commenting system again (another benefit: no unnecessary scripts = even more speed).

The thing is: my Varnish setup caches pages for an hour (and I'd like to keep that), which, of course, doesn't play nice along with static commenting systems.

Still reading? Great! So here's what I'd love to have: whenever someone publishes a comment, I want the Varnish cache to be purged (the page commented on, the index, the archive pages).

For this, I need to know how to trigger an action (http request, or, preferably, a CLI action) once the comment has been posted and a page rebuild is due. I suppose this could be done via a plugin, but alas, I don't know how to. If I had a plugin for this purpose, I'd need to pass alone the entry URI being commented on (Varnish is flexible with the rest, , ~ archive would flush the entire archive, ^/$ the index.).

Do you know how to do that? I think a general action on "publishing" and not just commenting would be fine, too, if it's triggered anyway.

Thanks in advance for any help that points me to the right direction. Eternal gratitude (and a mention upon a solution if desired) shall be yours!

Yours,
- Ben

Reported on Movable Type 5

7 Replies

| Add a Reply
  • Hi Ben,

    There is no solution for what you want at this time, not only with this CMS, but also with other CMS solution that I know of.

    However, this job could be achieved by coding a plugin which to flush the Varnish cache when an individual article page is regenerated.

    We could eventually code this plugin together as a consultancy item. How soon do you need it?

    Kind Regards,
    Mihai Bocsaru

    ----------------------------------
    Web Development
    Movable Type Consulting
    Six Apart Partner

    http://www.pro-it-service.com/
    ----------------------------------

    Movable Type Demo
    http://www.movabletypedemo.org/

  • Hey Mihai,

    thanks for taking the time to answer!

    Now, as - despite what my setup might suggest - this is of interest for my personal, non-commercial blog (nof.io), a commercial solution may be of interest (as long as it's affordable for a private person), but it's not on my top priority list. I hope you understand this.

    You're more than welcome to send me a cost estimate, though! If the price is right, and I don't find anything myself the next two days, I'll seriously consider this.

    Oh, by the way, for WordPress there are lots of plugins which just do this (I just don't want to use WP for my blog):

    Yours,
    - Ben

  • Repost (I think the attached link list marked this as spam.)

    Hey Mihai,

    thanks for taking the time to answer!

    Now, as - despite what my setup might suggest - this is of interest for my personal, non-commercial blog (nof.io), a commercial solution may be of interest (as long as it's affordable for a private person), but it's not on my top priority list. I hope you understand this.

    You're more than welcome to send me a cost estimate, though! If the price is right, and I don't find anything myself the next two days, I'll seriously consider this.

    Oh, by the way, for WordPress there are lots of plugins which just do this (I just don't want to use WP for my blog).

    Yours,
    - Ben

  • I think I'm onto something using the build_file callback. If I can pass the right argument (URI of the file being rebuilt), I might just have created (at least a base) for a general purpose Varnish cache purge plugin for Movable Type. Which would be awesome, of course.

    Thanks for pointing me in the right direction, Mihai!

  • Nice, I got a working plugin running — and it has the modest name "Varnish Cache Purge Plugin". It's even configurable! As of yet, it still needs manual installation of Varnish::API (the CPAN module), but if anyone is already interested (especially in enhancing and developing it further), just let me know, I'll gladly pass it along.

Add a Reply

If you need to share template code, replace all the "<" signs with "&lt;" or use this utility.

Forum Groups

code.sixapart.com

137 479

Last Topic: Getting a thumbnail with xpath by Peter on Mar 13, 2011

238 797

Last Topic: Manifest Schema Compatibility Issue When Restoring Blog by Matt on Oct 17, 2012

1858 6594

Last Topic: Categories and Basename Publishing Issues by e21media on Oct 25, 2012

88 307

Last Topic: absolute publish date in Manage Entries screen by .mau. on Apr 18, 2012

1488 5347

Last Topic: Anti-cloning by .mau. on Oct 29, 2012

732 3093

Last Topic: Blog moved server - now users cannot access blog? by mowgs on Oct 30, 2012

89 317

Last Topic: How to "pretify" a url in htaccess with a few wildcards by Caio on May 30, 2012

183 771

Last Topic: Commenting with TypePad by Rob Ferrara on Oct 17, 2012

212 680

Last Topic: Does MT-Approval work in MT5? by DLpres on Sep 25, 2012

27 100

Last Topic: Upgrading MT by Caio on Oct 15, 2012

49 224

Last Topic: Movable Type 6 Ideas by Caio on May 28, 2012

65 248

Last Topic: Expanding new rich text editor and implementing table function by Takeshi Nick Osanai on Jul 30, 2012