If you need to remove or update an image on imgix, you can purge it from our caches. Common reasons for purging an image are:
- An out-of-date or unwanted image is being served through your imgix Source (e.g. need to remove for DMCA compliance).
- You want to update an image in your Source without renaming the file.
Purging removes the image (e.g.
https://assets.imgix.net/dogs.png) from our caches, which then clears out all derivatives as well (
https://assets.imgix.net/dogs.png?w=400, etc.). The master image in your Source remains untouched by the purge operation.
- Remove or replace the image in your Source before triggering a purge request. All of the subsequent validation steps depend on your master image status being changed.
- Call the Purge API using just the base path to the image, with no parameters (e.g.
you.imgix.net/your-image.png). See Purge Request Methods below for different ways to do this. The request will purge all derivatives of this image, so you don't have to do each one individually.
- The API will return a
200status code if successfully received; this does not mean that the purge has completed yet.
- Test the result by fetching the image again.
- If you removed the image, you should receive a
- If you replaced the image, you should get the updated version.
Purges typically complete through the entire imgix system in <1 minute, but the system does not guarantee a completion time, so testing is highly recommended. To absolutely ensure compliance for an updated image, it's best to give the image a new path by renaming the file.
Using the Tools view in the imgix Dashboard is the easiest way to purge an image. Simply paste the imgix URL of the image you want to purge in the text box in the Purge Single Image section and click Purge.
If you're comfortable using the command line, it's the fastest way to purge an image. First, find your API Key on the Account page. Then simply plug it, and the URL of the image you want to purge, into the example below.
Below is an example of purging an image with Python and the Requests library.
imgix completes several options in sequence when a purge is requested:
- The request is revalidated against the image in your Source. If the image is unchanged (returns a 304 status code), then the purge process stops. This is why any changes to an image, such as replacement or removal, have to start with your master image at the Source.
- If the image registers as changed, then it's either removed or replaced by the new version in imgix's origin cache.
- A request is then sent to the imgix CDN to set the image's TTL to
0s, thus forcing revalidation on subsequent requests for both the master image and all derivatives.
Purging does not remove images from any of the following, because they are outside of the imgix system:
- Your Source (Amazon S3, Google Cloud Storage, etc.)
- Any third-party CDNs you might use in addition to the imgix CDN
- The end user's browser cache
- Any ISP caches between imgix and the end user
Because of this, it is still possible for the end user to see an out-of-date image on occasion. Please contact Support if you need help with purging operations.