The following code is written in PHP and assumes that the client knows only the domain and protocol of the Site Identity where it intends on purging the cache:
- The client goes to the discovery page and retrieves all Site Identities through the “siteidentites” link relation.
- The client parses the returned JSON, which includes embedded individual Site Identities, and finds the Cache Purge resource through the “cachepurge” link relation of the Site Identity that matches the correct domain and protocol.
- The client creates a cache purge job by making a POST request to the Cache Purge resource and grabs the URL of the cache purge job from the response (also available in the Location header) and prints this URL on the screen. At this point anyone can hit the cache purge job URL and be notified if the cache is still processing (Status Code 202 and processing message in JSON response) or if the cache purge is complete (status code 200 and completed message in JSON response).