WordPress.org

Forums

Varnish HTTP Purge
[resolved] Purge on new Posts in clearing all cache (20 posts)

  1. limeybloke
    Member
    Posted 9 months ago #

    Hi there,

    I've got everything up and running just fine but I've noticed when I post a new blog post all my cache is cleared.

    Should it not just purge the front page for this?

    Is this the intended set-up?

    https://wordpress.org/plugins/varnish-http-purge/

  2. limeybloke
    Member
    Posted 9 months ago #

    Just to clarify this, I have a static front page for my site. When I add a new Post the front page is flushed and it appears all other pages in the site as well.

    I'm using the Varnish VCL to linked to from Dreamhosts.

    I've tested this as I've got a page in my site that has a support panel listing all the latest blog posts. When I add a new post this is flushed as well.

  3. No, it should only flush the pages that are changed, and the front page. That includes tags and categories, mind you, so if you always use the same ones, they will get caught.

    How are you determining that the whole cache is flushed? Also what version of varnish are you on?

  4. limeybloke
    Member
    Posted 9 months ago #

    Hi there,

    So I'm using Varnish 3.0.5

    The pages I'm looking at have no relation to tags or categories which is why I'm puzzled.

    If you visit this page http://www.nlg.nhs.uk/hospitals/grimsby/getting-here/ you'll see in the side bar, we have a panel that pulls in the latest blog posts. This page here is simply a Page. I'm expecting this page to be cached and when I update the blog my side panel would become out-of-date as I'm not using EIS.

    If I then go in and add a new blog post. I'm expecting the front page (which is http://www.nlg.nhs.uk/news/) to be flushed but not the other page and it's totally independant.

    What happens is the Getting here page is also flushed and my side panel updated.

    I ran a few tests where I disabled the plugin and made a few random changes to other content pages. Then switched the plugin back on and added a new Post and and new changes are there. Which means when I add a new Post it is clearing all cache.

    Based on what you've described this shouldn't be happening - right?

    The side panel is using the following code;

    <?php
        $queryObject = new WP_Query( 'post_type=post&posts_per_page=3' );
        // The Loop!
        if ($queryObject->have_posts()) {
          while ($queryObject->have_posts()) {
            $queryObject->the_post(); ?>
            <article class="side-feed__item" role="article">
              <h3 class="item__heading"><i class="icon--chevron icon--inset"></i><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
              <div class="item__copy"><?php the_excerpt(); ?></div>
              <p class="item__meta">Posted <time datetime="<?php echo get_the_date('Y-m-d'); ?>"><?php echo get_the_date('d/m/Y'); ?></time></p>
            </article>
        <?php
  5. Do you have access to the varnish logs and if so, can you see what command is being sent to it when you post a page?

  6. limeybloke
    Member
    Posted 9 months ago #

    Yes I do but not entirely sure how to access them or to check what is being passed?

  7. When I get to a real computer tomorrow, I'll reply with directions on how to and what we're looking for. I'm on an iPad right now and can't get at my notes :(

  8. OKAY! So yesterday sucked.

    varnishncsa -F "%m %U"

    On our servers at DreamHost we run that to watch every process as it goes through.

    If you run that you'll see things like this:

    GET /wp-content/uploads/2013/09/1user_00.png
    GET /wp-content/uploads/2013/09/1user_01.png
    GET /wp-content/uploads/2013/09/geico-caveman-commercial-scrabble-i14-300x288.jpg

    And what you're looking for when you save a page is this:

    POST /wp-admin/admin-ajax.php
    GET /wp-includes/images/smilies/icon_wink.gif
    PURGE /category/intermediate/
    PURGE /tag/dreamhost/
    PURGE /tag/security/
    PURGE /tag/users/
    PURGE /tag/wordpress/
    PURGE /separate-users-are-good/
    PURGE /feed/rdf/
    PURGE /feed/rss/
    PURGE /feed/
    PURGE /feed/atom/
    PURGE /comments/feed/atom/
    PURGE /comments/feed/
    PURGE /separate-users-are-good/feed/
    PURGE /
    POST /wp-admin/post.php

    So that tells me everything I'm purging.

    If you see this:

    GET /wp-admin/
    PURGE /.*
    GET /wp-admin/

    It means the whole SITE was purged.

  9. limeybloke
    Member
    Posted 9 months ago #

    Morning and thanks for helping!

    So I posted a new Post and I got this.

    POST /wordpress/wp-admin/admin-ajax.php
    POST /wordpress/wp-admin/admin-ajax.php
    POST /wordpress/wp-admin/admin-ajax.php
    PURGE /category/announcements/
    PURGE /news/new-1-2/
    PURGE /feed/rdf/
    PURGE /feed/rss/
    PURGE /feed/
    PURGE /feed/atom/
    PURGE /comments/feed/atom/
    PURGE /comments/feed/
    PURGE /news/new-1-2/feed/
    PURGE /
  10. limeybloke
    Member
    Posted 9 months ago #

    I pressed the "Purge" button on the dashboard and got this;

    GET /wordpress/wp-admin/index.php
    PURGE /.*
  11. limeybloke
    Member
    Posted 9 months ago #

    This is very weird. I've just run a few more tests.

    I switched off the plugin.
    Made a change to a content page that doesn't have the side panel on.
    Switched the plugin back on.
    Posted a new post.
    And checked that page and the amend was now visible.

    So it's telling me the cache is being cleared each and every time a new post is posted.

    I've also noticed that if I delete a post it's not clearing the the side panel but is clearing everything else (i.e. the news home page etc).

    So when I deleted the post, my side panel is out of date which is what I would expect.

    The delete post resulted in;

    POST /wordpress/wp-admin/admin-ajax.php
    PURGE /category/awards/
    PURGE /news/new-3/
    PURGE /feed/rdf/
    PURGE /feed/rss/
    PURGE /feed/
    PURGE /feed/atom/
    PURGE /comments/feed/atom/
    PURGE /comments/feed/
    PURGE /news/new-3/feed/
    PURGE /
  12. Clearing the news page (ie the front page) is what I expect, it's a default page to flush... So yeah, it looks like the plugin is doing exactly what it's supposed to do.

    Are you perchance always logged in when you're looking? Varnish in general skips the cache when you're logged in.

  13. limeybloke
    Member
    Posted 9 months ago #

    Hi Mike,

    But it's not the front page that's being cleared here. That is as well.

    So when I post all pages are cleared.

  14. Unless THIS hits your log, you're not seeing all posts being cleared:

    PURGE /.*

    Or rather, it's not the plugin...

    The ONLY reason it might happen is if you set up Varnish so that this

    PURGE /

    meant to purge everything. And that's something you would have had to do on your vcl config, and I don't even know how to :/

  15. limeybloke
    Member
    Posted 9 months ago #

    I was using the Dreamhost VCL for purging seen here

    https://github.com/dreamhost/varnish-vcl-collection/blob/master/lib/purge.vcl

    Note there appears to be some reference to /

    Could this be the problem?

  16. PURGE / literally means 'Purge domain.com/'

    The whole reason that PURGE /.* means to use regular expressions and purge everything

    Sadly, I'm not enough of a varnish vlc expert to know why your install is treating / as a full domain purge, but I suspect that's what's happening.

    What version of Varnish are you on? Did you enable regex on it? (there's more than JUST the vcl to controlling varnish after all)

  17. limeybloke
    Member
    Posted 9 months ago #

    Thanks

    I'll check varnish version.

    Can you share the complete VCL you are using ?

  18. https://github.com/dreamhost/varnish-vcl-collection - Rather literally I'm testing it on DreamPress right now :)

  19. limeybloke
    Member
    Posted 9 months ago #

    Did you get it working with the VCL?

  20. That's the thing, it works exactly as it's supposed to for me (and hundreds of people). I think you have something else set that's treating a Purge on / the same as /* but I don't know what :(

Reply

You must log in to post.

About this Plugin

  • Varnish HTTP Purge
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.