# Required Cloudflare settings

## Correct loading of JavaScript chunks (Next.js)

Your site is proxied through Cloudflare and uses a modern frontend framework [Next.js](http://next.js/). JavaScript files (chunks) are loaded **dynamically** and **tightly bound to the site's build version**. With default Cloudflare settings it may:

* cache outdated JS chunks
* return script loading errors
* serve different file versions to different users

As a result, some visitors may experience incomplete loading or unstable behavior. The reason is that Cloudflare applies **default caching** to JavaScript files without considering: dynamic chunk generation, site updates, interdependence of chunks

## **Recommended solution**

Create a cache rule in Cloudflare. To do this you need to log into your Cloudflare and go to the **Rules-> Overview,** click the **Create Rule**button and select **Cache Rules**

![](https://2918865942-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp0ow3kIXHQDcl9DBdYiM%2Fuploads%2FSGQkM8APwR7PVAdSbmNl%2FUnknown%20image?alt=media\&token=873bd20d-24b6-43d4-87c1-ccea2aab50b6)

In the opened window you need to enter the rule name in the **Rule name**field. Then below you need to fill in the condition as shown in the example **Replace YOUR\_DOMAIN with your site's domain without https\://**

<figure><img src="https://2918865942-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp0ow3kIXHQDcl9DBdYiM%2Fuploads%2FNiQuXvIpyp45CEEewXXw%2FUnknown%20image?alt=media&#x26;token=63fb2c43-de08-4c84-8d4e-53f9760ccfec" alt=""><figcaption></figcaption></figure>

After entering the condition select the action **Bypass cache** and save the rule with the **Deploy.**

<figure><img src="https://2918865942-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp0ow3kIXHQDcl9DBdYiM%2Fuploads%2FZHvk1Iyh0uPMjFYpNNZP%2Fimage.png?alt=media&#x26;token=5db8600c-22f3-4660-b1aa-d20d5fe813c4" alt=""><figcaption></figcaption></figure>
