# Caching interval

## Token caching settings <a href="#od_1979b79e" id="od_1979b79e"></a>

CDN caching accelerates the loading times of images as it allows to host them as close as possible to your end users. By using CDN caching, your ensure maximum performance of your website. You can define the `max-age` and `s-maxage` attributes in the Cache-Control HTTP Header of images delivered by Cloudimage to control the caching behavior.

When this cache expired, the image will be requested from the origin and the new image delivered to the client. Reduce the default values if you have rotating images but static image URLs without versioning.

We recommend using [#od\_7ca0ab90](https://docs.cloudimage.io/cdn-basics#od_7ca0ab90 "mention") if you need to refresh your images as it will not impact your CDN cache-hit ratio.

| Directive  | Description                                                                                                                                                                                                                        |
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `max-age`  | <p>The time in seconds that the image is allowed to be re-used.<br>For instance, <code>max-age=36000</code> indicates that an image remains in the browser cache for the next 36 000 seconds (10 hours).</p>                       |
| `s-maxage` | <p>This directive applies only to the caching in CDN. To maximise performance,<br>we recommend you set a high value here and perform <a data-mention href="../cdn-basics#od_7ca0ab90">#od\_7ca0ab90</a> on images when needed.</p> |

If you have rotating origin images but do not change the name, you need to follow the chart:

<figure><img src="https://content.gitbook.com/content/IDIcmPiz7q6Sr6ZHHQxV/blobs/ckGQ08Ah9JAgSXTcWXTg/ci1.png" alt=""><figcaption></figcaption></figure>

### Setting default cache <a href="#od_fc6b7d38" id="od_fc6b7d38"></a>

You can see the values in your admin console, under *Image Settings* -> *Caching*.

<figure><img src="https://727245914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIDIcmPiz7q6Sr6ZHHQxV%2Fuploads%2FXnbQREsJhkp1n7GZbNBA%2Fcaching.png?alt=media&#x26;token=c2ea7814-2494-43ed-b4cb-290114ba43f1" alt=""><figcaption></figcaption></figure>

## Image caching settings <a href="#od_af320880" id="od_af320880"></a>

We can define the caching interval of a specific image by setting the **ci\_cache=X** URL parameter of the image where **X** is the interval in seconds.

[/sample.li/now.php?**ci\_cache=10**](https://doc.cloudimg.io/sample.li/now.php?ci_cache=10&)

This will override the `max-age` and `s-maxage` attributes only for this image.

{% hint style="info" %}
In order to change those settings, please contact our support.
{% endhint %}

### **Automatic origin image refresh**

<figure><img src="https://content.gitbook.com/content/IDIcmPiz7q6Sr6ZHHQxV/blobs/FArJ6FfhaSQgEzXZcCzi/ci3.png" alt=""><figcaption></figcaption></figure>

If you need to use a very small caching interval for a specific image (for example, snapshots from a live webcam or a specific chart with dynamically changing contents), you need to change the *Automatic origin image refresh* setting in your Admin console. This tells our resizing servers to update all origin images after this interval has expired.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cloudimage.io/caching-and-acceleration/caching-interval.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
