Clearing Content from the CDN Cache
This guide describes how to delete incorrect or accidentally published content from the CDN cache.
Caching enables particularly fast delivery of content to your website visitors. If content has been accidentally declared as cacheable or contains an error, you can remove it from the cache as follows.
Check if Content is Delivered from Cache
Use the following request to check if content is delivered from the cache:
Linux:
curl -I https://www.mywebsite.com/media/image/product/spaceeggs.png
Windows (PowerShell >= v3):
Invoke-WebRequest -Method HEAD -Uri https://www.mywebsite.com/media/image/product/spaceeggs.png
Windows (PowerShell):
$r = [System.Net.WebRequest]::Create('https://www.mywebsite.com/media/image/product/spaceeggs.png')
$r.Method = "HEAD"
$r.GetResponse().Headers['X-IDNT-Cache']
The following values of the X-IDNT-Cache header indicate whether the request was answered from the cache:
- HIT: The request was answered from the cache
- MISS: The request was not answered from the cache
Remove Content from Cache
If the request is answered from the cache, you can remove the content with the following request:
Linux:
curl -X PURGE https://www.mywebsite.com/media/image/product/spaceeggs.png
Windows (PowerShell):
$r = [System.Net.WebRequest]::Create('https://www.mywebsite.com/media/image/product/spaceeggs.png')
$r.Method = "PURGE"
$r.GetResponse().StatusCode.value___
If the content was successfully removed, you will receive a response with HTTP Status 204 (No Content). If the content was not found in the cache, you will receive a response with HTTP Status 412 (Precondition failed).