Should I URL encode the purge key when using the API?


#1

My purge keys have characters that need to be URL encoded, so when using the API Purge By Key call I think I should URL encode the key value. My question is – will this mess up the key value on Fastly’s end? (i.e. Will I be purging the wrong Surrogate-Key because it’s arriving URL encoded?)

Thanks!


#2

Your caution is valid. The Surrogate-Key Purge function will not work as expected if you URL encode the key value. Send the purge request based on how you expect the key values to be stored. We literally store them as they are written.

You can test your Surrogate-Key Purge using the cURL command:

curl -svo /dev/null <URL>
  • Run the curl command on a URL that is cached
  • Execute a Surrogate-Key Purge to invalidate the content
  • Run the curl command on the URL and view X-Cache:MISS

If you have issues, don’t hesitate to email us at support@fastly.com