Is it possible to purge the cache used for asset retention

Is it possible to purge the cache used for asset retention (or at least adjust the TTL)? I've noticed that some users can get an old version of a .json file i import into my next.js project which is not ideal for the site I'm running. Thanks! https://developers.cloudflare.com/pages/configuration/serving-pages/#asset-retention
Cloudflare Docs
Serving Pages · Cloudflare Pages docs
Cloudflare Pages includes a number of defaults for serving your Pages sites. This page details some of those decisions, so you can understand how …
11 Replies
Erisa
Erisa•9mo ago
The cache for asset retention should just be for assets present in one version and not in the next, it should not apply for files which were changed. Changed files should display immediately or near-immediately. Are you using a pages.dev or a custom domain? And if a custom domain, have you tried purging cache for the zone? As this may have its on cache running "in front" of the Pages cache
kerm
kermOP•9mo ago
strange. I am using a custom domain from namecheap. maybe Ill just host the JSON file as a static asset and do a fetch call for it in my code to ensure the newest version
Erisa
Erisa•9mo ago
The custom domain is not using Cloudflare nameservers?
kerm
kermOP•9mo ago
Sorry yes it is, but I did purge the cache after changing the JSON file but it seems like there was still a user that got the outdated version of the file Maybe the user had the outdated file downloaded in their browser? I'm not sure how this could have happened
Erisa
Erisa•9mo ago
Its possible there was browser cache involved? Would depend on the way the json is fetched I suppose.
kerm
kermOP•9mo ago
I believe it was incldued with the webpack since I essentially "imported" it into my page.tsx file https://stackoverflow.com/a/68930283
Stack Overflow
Loading content from a static JSON Next JS
I have Next JS project with static JSON placed in /pages/api/data.json that looks like this: { "Card": [ { "title": "Title 1", "content": "Content 1...
kerm
kermOP•9mo ago
but yeah if browser cache is involved then changing it to be a fetch probably wouldn't help. I've seen this happen a handful of times now
Erisa
Erisa•9mo ago
Normally with webpack and such I would expect the filenames to all be hashed so that one changing without another one wouldnt be an issue (and asset retention keeps the old ones around for a time) Not so sure about how this interacts with next.js particularly though
kerm
kermOP•9mo ago
ohhh fascinating so asset retention may be kicking in since future webpacks have different filenames?
Erisa
Erisa•9mo ago
Would need data from a concrete example to say with any certainty whats happening 😅
kerm
kermOP•9mo ago
that's the thing is I have no idea how to replicate it 😭 I did just add a cache rule to disable caching for my pages domain as I heard that can cause some issues with cache invalidation. I guess I'll just have to wait and see if the issue comes up again but changing the pages.tsx file to fetch instead of importing the JSON doesn't seem to have fixed anything? still got 1 user get stale JSON data today. which is very strange considering that data is close to a week old at this point disabled the cache rule real quick to see and here's the header of the data in question
Request URL:
https://relatle.io/
Request Method:
GET
Status Code:
200 OK
Remote Address:
104.21.25.18:443
Referrer Policy:
strict-origin-when-cross-origin
Alt-Svc:
h3=":443"; ma=86400
Cf-Cache-Status:
DYNAMIC
Cf-Ray:
863186546edd6835-SEA
Content-Encoding:
br
Content-Type:
text/html; charset=utf-8
Date:
Tue, 12 Mar 2024 05:53:35 GMT
Nel:
{"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Report-To:
{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=hEM7w3g1eDcxGkn1Nh6JrulmmZM5d5irXY6UBXvEh92W07Ix5Npc9lAoBclqu5iyjE4GqrNBNsZSi2gbABvPeOjfTamBxWCaIkcnYMK8xadO5WUgh7flwvTKECGh"}],"group":"cf-nel","max_age":604800}
Server:
cloudflare
Vary:
RSC, Next-Router-State-Tree, Next-Router-Prefetch, Next-Url, Accept-Encoding
X-Edge-Runtime:
1
X-Matched-Path:
/
X-Powered-By:
Next.js
:authority:
relatle.io
:method:
GET
:path:
/
:scheme:
https
Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding:
gzip, deflate, br, zstd
Accept-Language:
en-US,en;q=0.9
Sec-Ch-Ua:
"Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"
Sec-Ch-Ua-Mobile:
?1
Sec-Ch-Ua-Platform:
"Android"
Sec-Fetch-Dest:
document
Sec-Fetch-Mode:
navigate
Sec-Fetch-Site:
none
Sec-Fetch-User:
?1
Upgrade-Insecure-Requests:
1
User-Agent:
Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Mobile Safari/537.36
Request URL:
https://relatle.io/
Request Method:
GET
Status Code:
200 OK
Remote Address:
104.21.25.18:443
Referrer Policy:
strict-origin-when-cross-origin
Alt-Svc:
h3=":443"; ma=86400
Cf-Cache-Status:
DYNAMIC
Cf-Ray:
863186546edd6835-SEA
Content-Encoding:
br
Content-Type:
text/html; charset=utf-8
Date:
Tue, 12 Mar 2024 05:53:35 GMT
Nel:
{"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Report-To:
{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=hEM7w3g1eDcxGkn1Nh6JrulmmZM5d5irXY6UBXvEh92W07Ix5Npc9lAoBclqu5iyjE4GqrNBNsZSi2gbABvPeOjfTamBxWCaIkcnYMK8xadO5WUgh7flwvTKECGh"}],"group":"cf-nel","max_age":604800}
Server:
cloudflare
Vary:
RSC, Next-Router-State-Tree, Next-Router-Prefetch, Next-Url, Accept-Encoding
X-Edge-Runtime:
1
X-Matched-Path:
/
X-Powered-By:
Next.js
:authority:
relatle.io
:method:
GET
:path:
/
:scheme:
https
Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding:
gzip, deflate, br, zstd
Accept-Language:
en-US,en;q=0.9
Sec-Ch-Ua:
"Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"
Sec-Ch-Ua-Mobile:
?1
Sec-Ch-Ua-Platform:
"Android"
Sec-Fetch-Dest:
document
Sec-Fetch-Mode:
navigate
Sec-Fetch-Site:
none
Sec-Fetch-User:
?1
Upgrade-Insecure-Requests:
1
User-Agent:
Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Mobile Safari/537.36
Seems like it was being cached (no no-cache present) and I'm not sure if the max-age there is accurate but if so that would come out to 7 days 🤔 The great news is that enabling that cache rule now has that file coming back with Cache-Control: no-cache so seems promising 🤞
Want results from more Discord servers?
Add your server