Purging with surrogate keys

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:

  1. Log in to the Fastly web interface.
  2. From the Home page, select the appropriate service. You can use the search box to search by ID, name, or domain.
  3. From the Purge menu, select Purge key. The Purge key window appears.

    a purge by url

  4. In the Keys field, enter one or more surrogate keys. Use spaces to separate multiple keys.
  5. Optionally select the Soft purge checkbox to mark your content as outdated instead of deleting it from cache.
  6. Click the Purge button.

You can also use our Purge API to purge objects via key.

What's next

Explore the other purging methods available with Fastly such as purging a URL and purging all content.

Back to Top