How to create surrogate tag by API


#1

HI Fastly
I want to create a surrogate key to my batch URLs ,
Is there any API can be used for this ?
Is there any api can be used to check surrogate config ?


#2

Hi-

Surrogate keys are created by adding a Surrogate-Key: header rather than via an API. It’s something that needs to be done prior to the caching of the object, so it can’t be done retro-actively. Typically we see customers send them from their origin, or in their custom VCL via beresp.http.Surrogate-Key such as:

  if (beresp.status == 404) {
    set beresp.http.Surrogate-Key = "404";
  }

You can see if an object has a surrogate key by sending a Fastly-Debug:1 header with your request.