Purging with surrogate keys
Last updated 2022-11-09
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. If you're new to the concept of purging, however, we recommend familiarizing yourself with our purging basics guide.
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.
Explore the other purging methods available with Fastly such as purging a URL and purging all content.
Do not use this form to send sensitive information. If you need assistance, contact support.