Contentful logo

Contentful Community

Is it possible to purge the CDN cache?

I was looking into the CDN aspect of Contentful and was wonder about caching.

Yesterday I created and published an image and got the asset’s direc URL on the CND back via the API, i.e. https://images.ctfassets.net/[space-name]/[asset-id]/[version?]/[file-name].jpg

I then unpublished the image and noticed that the file was still available at that URL. I tried to overwrite the image with a 1x1 pixel white square & that had no affect after a repubish.

So was just wondering,

  • if it’s possible to purge an image from the cache?
  • what’s the default TTL of something that’s cached on the CDN?
  • if it’s considered ‘safe’ to expose CDN URLs to an end-user?

I’m just thinking about cases like e.g. I accidentally publish “company-trade-secrets.pdf” rather than “company-december-press-release.pdf”.

(Apologies if I missed this in the docs or an old forum post, I did search both but couldn’t find a topic on it.)

Hi Dave,

To answer your questions:

  1. It’s not possible to do so but, if you’d like to, you could send us an email to our support channel and we will manually purge that for you.

  2. Once an asset is uploaded and thereby an image link is generated, it will be indefinetely stored in our servers, even if you later modify it and a new URL is generated. Because of that, if you’d like to permanently delete these assets, you’d have to contact us directly to do so.

  3. In terms of assets, it is surely safe to expose them to an end-user, but API calls that would on the other hand utilize an access token (e.g. retrieving an entry) should not be directly available to your broader audience.

Hi Gabriel,

thanks for getting back. Are there any plans to, e.g. adding something to the API to control the files on the CDN?

In terms of linking directly to assets, I was thinking of things like progressive web apps (where a user might have a version of the HTML up to 24hrs old), which is harder for developers to have direct control over. It would be very useful to be able to programmitcally expire old content to ensure it’s fully taken offline.

Thanks
Dave

Hi Dave,

We indeed wouldn’t have such an implementation at the moment, but I will make sure to send this feedback to our product team. :slight_smile: