> ## Documentation Index
> Fetch the complete documentation index at: https://spreecommerce.org/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# CDN

> Learn how to improve performance of your Spree application by using a CDN (Content Delivery Network).

To improve performance of your Spree application, we recommend using a CDN (Content Delivery Network) to cache images and static files.

We recommend using [Cloudflare](https://www.cloudflare.com/) as your CDN provider. It's free and simple to setup.

After setting up your Cloudflare account and adding your domain name to Cloudflare, you will need to set your cache settings.

Go to your domain name in Cloudflare and click on "Caching" tab and select "Cache Rules".

<img src="https://mintcdn.com/spreecommerce/OgdQHBPQ0RbaKyDN/images/developer/deployment/cloudflare_caching.png?fit=max&auto=format&n=OgdQHBPQ0RbaKyDN&q=85&s=fad8fc747a5d83487ae5364e7e2e8261" alt="Cloudflare Cache Rules" width="510" height="382" data-path="images/developer/deployment/cloudflare_caching.png" />

Click on "Create Rule" and setup the rule as bellow:

<img src="https://mintcdn.com/spreecommerce/OgdQHBPQ0RbaKyDN/images/developer/deployment/cloudflare_cache_rule_1.png?fit=max&auto=format&n=OgdQHBPQ0RbaKyDN&q=85&s=9293f7d03f5c003008f168b7a17d59a4" alt="Cloudflare Cache Rule Settings" width="2110" height="1368" data-path="images/developer/deployment/cloudflare_cache_rule_1.png" />

Supply the first value with

```url theme={"theme":"night-owl"}
/rails/active_storage/representations/
```

and the second value with

```url theme={"theme":"night-owl"}
/assets
```

This will handle caching of both images and static files such as JavaScript and CSS files.

Now scroll down and set the settings as bellow:

<img src="https://mintcdn.com/spreecommerce/II6sKnqAuUp3_6IP/images/developer/deployment/cloudflare_cache_rule_2.png?fit=max&auto=format&n=II6sKnqAuUp3_6IP&q=85&s=65a41fb65c6af06e8154ed85a78e2b07" alt="Cloudflare Cache Rule Settings" width="2136" height="1778" data-path="images/developer/deployment/cloudflare_cache_rule_2.png" />

Finally, click on "Deploy" and you are done!
