Setting Surrogate-Key headers based on a URL
Follow these instructions to set Surrogate-Key headers based on a URL:
- Log in to the Fastly application.
Click the configure tab (wrench icon).
From the Service menu, select the appropriate service and then click the blue Configure button. The main controls for the selected service appear.
Click Content from the section list on the left.
In the Headers area at the top of the page, click the New button. The New Header window appears.
Fill out the New Header fields as follows:
- In the Name field, type a human-readable name for the header.
- From the Type menu, select Cache. From the Action menu, select Set.
- In the Destination field, type
- In the Source field, type
regsub(req.url, "^/(.*)\.(.*)$", "\1"). This will accept a URL that looks like
/foo.htmland will create the Surrogate-Key
- From the Ignore If Set menu, select No.
- In the Priority field, type
Click the Create button to create your header.
To publish the new header, deploy the version of the service you are editing.