Introduction
Why purge images?
ImageEngine retains an image in its cache for the length of time specified by the image's Time-To-Live (TTL). When the TTL expires, ImageEngine will refresh the image from the origin. Users can modify the TTL by Customizing An Engine's Settings. Users can also purge an image to immediately force a refresh. We provide an interface that allows purging a single image or purging many images that match a provided pattern all at once.
Please note that each Engine maintains its own cache.
Why you might not want to purge images
Especially with time-sensitive items, Image versioning should be used wherever possible instead of relying on purging old versions of images.
For instance, these two URLs will link to the same image name but each is treated as its own instance. Using image versioning ensures that the newest version is pulled from the origin when the change occurs on your site.
Examples:
- https://foo.com/images/172609.jpg?v=1234
- https://foo.com/images/172609.jpg?v=1235
Note the new number following the “?v=” sign for the second URL
You do not necessarily need to version at the origin. You may update the image at the origin, and increment their version(s) in the site code that references the image.
How can I purge the cache?
The Cache Purge interface can be accessed from the control panel’s left-hand menu in an engine's dropdown list:
Or by clicking the 'Purge Cache' option on an engine’s overview:
When opened, the purge interface looks like this:
Purge process
To start a purge,
- Enter an Expression defining the desired image(s).
- As an optional step, click the box next to the Expression box to open a path validation modal:
- As an optional step, click the box next to the Expression box to open a path validation modal:
- Click "Submit Purge Request" to initiate the process. This will put the cache purge request in ImageEngine’s queue for completion.
- You can check the status of the purge request in the list of purge requests. Please allow a moment for the purge request to be executed in all regions.
Note: The purge execution time is impacted by the number of purge requests in the queue. DO NOT execute duplicate purges in rapid succession.
Expression Usage
ImageEngine uses patterns to identify what images to purge from its cache. A pattern defines a single image or a group of images.
When cache-purging, each request must contain only one pattern (no multiples, no spaces). Images with matching URIs will be removed from the ImageEngine cache.
All cached image variants of the same name will be purged.
For example, purging
/media/this/path/images/12345.jpg
would purge all image variants (size and format) of the same name
/media/this/path/images/12345.jpg
See this article for a full list of pattern values
Warning!: Invalidating your entire cache using /**/*` is not advisable. Purging everything all at once will result in performance degradation temporarily as images are being re-cached. To avoid this, only purge subsections at a time.
Sample use case:
Replacing a single image
- A new image has been uploaded, at foo.com/media/brands/example.jpg. The content is being served through ImageEngine using the delivery address "images.foo.com"
- A cache purge is performed using "/media/brands/example.jpg", making sure to select the correct delivery address (images.foo.com as mentioned above). The purge is then started
- A short time afterward executing the purge, the old example.jpg image has been removed and the new image is beginning to be cached.
Note: If replacing all images under the "brands folder" was desired, the pattern "/media/brands/**/*" may have been used instead to purge all of the images present there in one action.
Troubleshooting: Old image is still being served after the purge
- Check whether the pattern being used is valid for the image
- Some other caches may still have the image cached. For example, some CMS systems retain their own image cache and may need to be cleared before ImageEngine has access to the new image. In such a case, you will need to clear the cache outside of ImageEngine
- Please note that ImageEngine cannot control whether a visitor has an old file saved in their browser's cache, as no one can programmatically erase a visitor's cache. This potential issue can be avoided by using image versioning, as discussed in the introduction of this article.
Please get in touch with us at support@imageengine.com if you are experiencing any issues after attempting a purge. We will be happy to assist you in determining the issue.
Comments
0 comments
Please sign in to leave a comment.