Purging with surrogate keys
Last updated 2021-12-06
Fastly provides several levels of cache purging and choosing the right purging method is essential to keeping your website fast. While Fastly's purge all is a speedy way to invalidate your cache, it may temporarily increase your website's load time while the cache rebuilds. If you find yourself purging all cache on more than a weekly basis, consider using surrogate keys for more targeted purging.
Surrogate keys are unique identifiers that you assign to portions of content that share common traits, making them easier to process as groups in some way. Using the
Surrogate-Key header, you can tag an object, such as an image or a blog post, with one or more keys. When you need to explicitly remove content from the Fastly edge cache, rather than allowing it to expire or to be evicted, you can use surrogate keys to purge groups of content selectively instead of purging all content.
Before you begin
This guide assumes you're already familiar with how to work with the
Surrogate-Key header to tag related pieces of cacheable content.
Purging objects with surrogate keys
You can use the Fastly web interface to manually purge objects via key:
- Log in to the Fastly web interface.
- From the Home page, select the appropriate service. You can use the search box to search by ID, name, or domain.
From the Purge menu, select Purge key. The Purge key window appears.
- In the Keys field, enter one or more surrogate keys. Use spaces to separate multiple keys.
- Optionally select the Soft purge checkbox to mark your content as outdated instead of deleting it from cache.
- Click the Purge button.
You can also use our Purge API to purge objects via key.