Purge by url with wildcards


#1

At the very least, it would be nice if the “purge by url” supported a trailing wildcard (*).
For example, this would allow purging of all derived images from a WordPress site when an image attachment is modifed/updated:
When you upload, you might have my-awesome-image.jpg, but WordPress creates my-awesome-image-150x150.jpg, and my-awesome-image-300x400.jpg, etc. It would be very handy to be able to purge these with a single API call.
While it’s possible to do the above by querying the attachment metadata in WordPress, it is very possible to have other derivative images which are not accounted for in the metadata, like Retina images and some theme-derived images.

Thanks!


#2

KeyCDN uses nginx and if they use nginx modules for caching then you should be able to purge by wildcard even if they don’t officially say they support it. Please try it using their GUI and let me know how you get on :slight_smile:


#3

I had that thought as well, but couldn’t find anything documented. So I’ll have to give it a test run and see what happens. It would be a huge help if it actually worked!


#4

I did a test with several images, made sure all the cache servers were primed properly. Then did a wildcard purge that would affect all of them, and it worked! They all showed “X-Cache: MISS” after the purge.
I’ll have to double-check that it works via the API, but see no reason why it shouldn’t. Thanks for the nudge, @iahmed.


#5

@nosilver4u Great news. What is the syntax you use for a wildcard cache purge?

thanks


#6

Just use an asterisk (*) at the end, but I’m honestly not sure the exact syntax offhand, because they’ve changed the interface, or my memory is failing me. It used to specify that you needed to include the zone name (not the alias), but that isn’t there anymore, and the example they give is with a relative url.