Fastly provides a Soft Purge feature that allows you to mark content as outdated (stale) instead of permanently purging and thereby deleting it from Fastly's caches. Objects invalidated with Soft Purge will be treated as outdated (stale) while Fastly fetches a new version from origin. You can purge by URL or by surrogate key using Soft Purge.
Before using Soft Purge, we recommend you implement one of the following revalidation methods:
- Set up
Last-Modifiedheaders for relevant content on your origin servers.
stale_while_revalidateto 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_errorat the same time.
To implement 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: __API_KEY__' -H 'Accept: application/json' https://api.fastly.com/service/<SID>/purge/<S-Key>