Soft purges

Fastly provides a Soft Purge feature that allows you to mark content as outdated (stale). Stale objects remain available to use in some circumstances while Fastly fetches a new version from origin, unlike objects invalidated by a hard purge which are made immediately unusable. You can purge by URL or by surrogate key using Soft Purge.

Before using Soft Purge, we recommend you implement one of the following methods to verify a stale object should temporarily remain in cache during revalidation:

  • Set up ETag or Last-Modified headers for relevant content on your origin servers.
  • Configure stale_while_revalidate to serve stale content and fetch the newest version of the object from origin in the background. If you choose this revalidation method, you must also configure stale_if_error at the same time.

To enable Soft Purge, add a Fastly-Soft-Purge request header (such as Fastly-Soft-Purge: 1) to any single URL or key-based purge.

To purge the URL www.example.com with Soft Purge, you would issue the following command:

1
$ curl -X PURGE -H "Fastly-Soft-Purge:1" http://www.example.com

To purge a surrogate key with Soft Purge, you would issue the following command:

1
$ curl -X POST -H 'Fastly-Soft-Purge:1' -H 'Fastly-Key: YOUR_FASTLY_TOKEN' -H 'Accept: application/json' https://api.fastly.com/service/<SID>/purge/<S-Key>
Back to Top