Cloudflare pages caching issue

Hi, we have an ongoing issue with caching. We use “wrangler pages publish …” to deploy our Cloudflare pages site. The main entry point for this page is /widget.min.js and we have a number of different Cloudflare operated domains for testing and production. Here’s an example of one of them, it’s linked to a .dev site:


The issue is, that following a publish of the site, when web pages request the widget, e.g. https://pay-qa.remuno.com/widget.min.js, the old pre-deployment version of the file continues to show up in the browser and when I manually request the file with curl. This can continue for up to an hour or so. Here’s an example after deployment which gives the old version:

curl -I https://pay-qa.remuno.com/widget.min.js
HTTP/1.1 200 OK
Date: Wed, 28 Jun 2023 11:37:27 GMT
Content-Type: application/javascript
Connection: keep-alive
Access-Control-Allow-Origin: *
Cache-Control: public, max-age=14400, must-revalidate
ETag: W/"b952134904bf12e1d8be8aa12d9543d4"
referrer-policy: strict-origin-when-cross-origin
x-content-type-options: nosniff
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=fjbkIpfgmn3307HD8Xr7sj6UURKiBoDkDZSp3s2BIF
P7ngENAniHgQoSDuDhAI86SqyeHpjHM7CHKqAB%2B1koynjq4eTWPeUHn9G0hm4LolPpVTDkTcvlwkILv37zrBpzcqhoZg%3D%3D"}],"group":"cf-nel"
,"max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Vary: Accept-Encoding
CF-Cache-Status: HIT
Age: 7079
Server: cloudflare
CF-RAY: 7de5a34decac71a5-LHR
alt-svc: h3=":443"; ma=86400

If I ask to skip caching, I get the correct version of the file:

curl -H "Cache-Control: no-cache" -I `https://pay-qa.remuno.com/widget.min.js`
HTTP/1.1 200 OK
Date: Wed, 28 Jun 2023 11:37:38 GMT
Content-Type: application/javascript
Connection: keep-alive
Access-Control-Allow-Origin: *
Cache-Control: public, max-age=14400, must-revalidate
ETag: W/"92127a1ed7b6ebae771a36780072720e"
referrer-policy: strict-origin-when-cross-origin
x-content-type-options: nosniff
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=E4bcnZ7xF95rpw1XZSLFI4vOvjPMYmDGU2XuuNlKzA
NnjMVqiXQmkzG9sd1UJLVV3pDe9F3xDgYYMWXlY1WsvhshIUdvqzGEMpqUKjuYzG8Lt38O1VDZuDMDCFdJapOGFvk8Wg%3D%3D"}],"group":"cf-nel","
max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Vary: Accept-Encoding
CF-Cache-Status: MISS
Server: cloudflare
CF-RAY: 7de5a38f484f071e-LHR
alt-svc: h3=":443"; ma=86400

Is there anything explicit I need to do with caching to avoid this situation?

Pages has its own internal cache, that does not reflect in the cf-cache-status header. It is recommended to disable the normal zone cache, you can do so easily with a cache rule https://dash.cloudflare.com/?to=/:account/:zone/caching/cache-rules/new:


If you have more then one hostname you want to skip, you can use the operator is in and type them out.

5 Likes

Thanks for the advice Chaika - much appreciated. We’ve put this in place and we’ll monitor on our next deployment. Will return and confirm if fixed.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.