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:

$ 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:

$ 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>
TIP

Purge all requests cannot be done as a soft purge and will always immediately invalidate all cached content associated with the service. To do a soft purge all, consider applying a constant surrogate key tag (e.g., all) to all objects.

Was this guide helpful?

Do not use this form to send sensitive information. If you need assistance, contact support. This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.