Purging with response


#1

When Fastly sends request to a backend it can respond w/ ‘Surrogate-Keys’ header to set up caching associations. Is it possible to remove those associations with the same response?
E.g. backend provides ‘Purged-Surrogate-Keys’ while responding with the list of keys to purge (e.g. keys which were affected during the request) so there is no need to hit Fastly API in background w/ every single key from this list. This should both increase cache invalidation speed and reduce traffic between Fastly and a backend.
Another option can be bulk purge API which accepts multiple surrogate keys at once.


#2

Hi-

The short answer is no.

The cached objects would retain their Surrogate-Key associations until they refreshed with objects that didn’t have them.

i.e. once an object is cached, there’s no changing the headers until that object refreshes/purges.

There currently isn’t a way to purge multiple SKs at the same time, but you can have multiple keys on objects as well (there’s 16k of keyspace available with a 1k limit for any individual key). This provides users the flexibility to create surrogate keys that capture different types of associations.

Hope this helps.


#3

Hi Peter,

Ignore the Surrogate-Key header for the sake of the current discussion. This is actually a feature request for a hypothetical Purge-Surrogate-Keys header, which would instruct Fastly to purge the listed keys, thus saving a number of round-trips between the customer application and the API.


#4

We also facing random fastly connectivity issues like connection reset by peer while trying to send purge requests so if we were able to purge keys with response using the connection fastly already has to our backend - that would be really useful and reliable.