This topic came up a while ago when Acquia was looking to introduce Soft Purge as an option for their Acquia purge module in Drupal (N.B. not to be confused by the Fastly Drupal module). There appears to be some confusion about what Fastly Soft Purge is, when it is useful, and how to use it. This post will help clear this topic up. What is Fastly Soft Purge?In Varnish, to force a miss for an object in cache you have a couple of options
So the main difference with Fastly Soft Purge is that the object persists in cache, and can be used in a stale context. This can prove to be extremely useful. When is Fastly Soft Purge useful?I would say Fastly Soft Purge should be used in 99.99% of all purges. There are extremely limited situations in which I would recommend Fastly Instant Purge:
It boils down to making a whoopsie really, and I would imagine the vast majority of your purges should (hopefully) not fall into these categories. Having a stale object is cache is useful as it:
How to use Fastly Soft PurgeJust because you execute a purge to Fastly does not mean you will instantly get any benefit, you also need to combo this with some "Stale Content Options" to which I will go through. If you are using the Fastly Drupal module, Soft Purge is configured like so: And as for Stale Content Options, you need to ensure that both "Stale while revalidate" and "Stale if error" are enabled. These are some basic tuning for the values as well: If you are not using Drupal (or using the Acquia purge module), then you can always set the above HTTP headers manually. See the Fastly documentation on this. Wait, I want to learn moreIf you want to go deeper in Varnish (what powers Fastly), and how objects, TTL, stale and grace (stale-while-revalidate) are involved, please see their documentation. There is also this excellent graphic to which explains how an object goes from fresh to stale GotchasIf you use Fastly shielding (which you probably should), then there is the potential for soft purged content on the edge PoP to end up being re-cached as fresh ?. See the Fastly documentation on this. There is a VCL snippet to mitigate this: If you are not already using Fastly shielding, and you care about caching, and cache hit rates, you should really start to look at this. The benefits far outweigh the tiny edge cases. P.S. if you are not already using the Fastly purge auth snippet, get this installed ASAP. By not doing this, a bad actor is able to purge any single URL on your site, in an instant fashion. This could create a DoS. CommentsIf you have any other pro tips when it comes to soft purging in Fastly, please let me know. Originally from Drupal.org aggregator https://ift.tt/3EzkZ3Z
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
April 2023
Categories |