Knowledgebase

Portal Home > Knowledgebase > CDN > Cache management > Fastly - how to Purge by Surrogate Key


Fastly - how to Purge by Surrogate Key




The Fastly CDN allows for fast, sub-second purging of content. 

The regular purge command is by URL, for example like this: 
curl -X PURGE http://url-of-asset-to-purge 

To have better context sensitive control over the purging process, you can associate a surrogate key to every piece of content, and then purge by key. 

To associate a surrogate key with content, add a header on your origin that specifies at least one surrogate key. Related content can share the same key. 

HTTP/1.1 200 OK
Surrogate-Key: key1 key2 key3
Content-Type: text/html

To purge a specific surrogate key, POST a request like this: 
 POST /service/<service-id>/purge/<surrogate-key>
 Fastly-Key: d3cafb4dde4dbeef
 Accept: application/json 


Replace <service-id> and <surrogate-key>  with your values

Links: 
http://www.fastly.com/blog/surrogate-keys-part-1#.UvpEiWKSw7s
https://fastly.zendesk.com/entries/21921227-How-can-I-purge-content-on-Fastly-
http://docs.fastly.com/api/purge#purge_3 



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
HTTP 304 code explained (Views: 1103)

Language:

Improve your web performance, reduce costs and boost ROI!

Contact us today