# CDN basics

Cloudimage leverages Content Delivery Networks to accelerate the delivery of your images worldwide. We work with multiple CDN providers to optimise the delivery of your images and provide superb reliability.

In addition to accelerating your images, the CDN provides DDoS (Distributed Denial of Service) protection, which will act as a shield to your servers and avoid any downtime.

CDNs cache images for faster delivery. They usually keep assets cached as long as it is stated in [the caching directive](https://docs.cloudimage.io/caching-interval#od_1979b79e).\
When the original image changes, the CDN won’t automatically detect that, so you need to either change the image URL or invalidate the cached version.

## Invalidation <a href="#od_7ca0ab90" id="od_7ca0ab90"></a>

To refresh your images, you can either update the Cloudimage URL or invalidate them to flush them from the resizing servers and the CDN.

### Option 1: add version parameter to the origin URL to force the CDN to download the new image <a href="#od_7f43aaf9" id="od_7f43aaf9"></a>

Old image:

//<mark style="color:blue;">**doc**</mark>.cloudimg.io/<mark style="color:red;">**sample.li/flat.jpg**</mark>?<mark style="color:orange;">**w=500**</mark>

New image:

//<mark style="color:blue;">**doc**</mark>.cloudimg.io/<mark style="color:red;">**sample.li/flat.jpg**</mark>?<mark style="color:orange;">**w=500**</mark>&**vh=xx**  (where **'xx'** represent random numbers)

{% hint style="info" %}
The `vh` parameter with any random value makes the URL unique and forces a cache refresh.
{% endhint %}

### Option 2: invalidate images from the Admin panel <a href="#od_9ed1870b" id="od_9ed1870b"></a>

If you cannot change the image URLs when changing the origin image, you can still invalidate (flush) the image from the Cloudimage admin console. Log in to the console and navigate to *Invalidation,* or go to this page - <https://admin.cloudimage.io/project/invalidation>&#x20;

First, you need to select the scope of the Invalidation:

* ***Original*** -> targets specific image URLs. Enter up to 10 URLs, separated by commas or line breaks.
* ***All*** -> this option will erase the entire cache generated for your token. Please use it with caution, because after invalidation, the cache needs to be rebuilt, and your first requests would take more time for execution.&#x20;

Do not use the full path of your image but only the **origin\_image\_url** part as invalidation path. \
For example, to invalidate `doc.cloudimg.io/sample.li/flat1.jpg?w=500`, you need to input `/sample.li/flat1.jpg`.

:green\_circle: Correct format for invalidation:  `/sample.li/flat1.jpg`\
:red\_circle: Incorrect formats for invalidation:\
`/sample.li/flat1.jpg?w=500`\
`doc.cloudimg.io/sample.li/flat1.jpg`\
`doc.cloudimg.io/sample.li/flat1.jpg?w=500`

<figure><img src="https://727245914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIDIcmPiz7q6Sr6ZHHQxV%2Fuploads%2F1cuvbUD23VseE9XVvigN%2Fimage.png?alt=media&#x26;token=d8500279-b8f7-4112-b0fe-e6e0acd32efd" alt=""><figcaption></figcaption></figure>

This will remove the image(s) from all CDN nodes and Cloudimage resizing servers.

When the Invalidation request is submitted, it appears in the Invalidation log. Both manual and [automatic invalidations](https://docs.cloudimage.io/caching-and-acceleration/invalidation-api) are logged there.

#### Details of the Invalidation Log

Every request has the following parameters:

* Status - the status of the request:
  * **Received** - request received successfully
  * **Preparing** - the Invalidation server prepares the request for execution
  * **Flushing Scaleflex servers** - deleting the cache in the resizing servers
  * **Flushing CDN servers** - deleting the cache of the CDN servers
  * **Done** - the invalidation finished successfully
  * **ERROR\_CDN\_NODE** - error in the CDN invalidation step
  * **ERROR** - general error in some of the invalidation steps

{% hint style="info" %}
If you encounter ERROR or ERROR\_CDN\_NODE, click **Retry** or [contact support](https://scaleflex.zendesk.com/hc/en-gb/requests/new). Please include the **Invalidation ID** in your message.
{% endhint %}

* Scope - the scope of the request (original / all)
* Date - the datetime when the request has been submitted for execution. The value is in the local time zone.
* Invalidation ID - the unique identifier of the request.&#x20;
* Invalidation path - if you click on "See links", you can inspect which URLs have been requested for invalidation (applicable for the invalidations with scope "original")
* Retry - resend the invalidation request if it failed.

Click the **Refresh** button to reload the invalidation log and view the latest updates.

### Option 3: use the Invalidation REST API <a href="#od_e63cfd84" id="od_e63cfd84"></a>

You can also automate invalidations by calling the [Invalidation API](https://docs.cloudimage.io/caching-and-acceleration/invalidation-api). This is useful for developers managing large-scale projects or CI/CD workflows.
