Re-fetching is showing a cached result on data from my own worker

Hello everybody hoping for quick response…going crazy on this.

I have create a worker that on first load is using fetch() to populate the page with some json data coming from a remote route in my worker

ie: fetch(’/api/something’)
AND is calling from remote 3rd party.
ie: fetch(‘https://3rdpartyapisomethingelse’)

When some activity occurs from somewhere else, the activity will update the 3rd party data and my kv stored data via a single meta data change(ie i have set a metadata field status will change from ‘pending’ to ‘accepted-live’). ANd in my response, all the metadata is shown.

Simple stuff! The issue is, i have created a reload button on the page that simply calls my init() function that is using fetch to re-call the same url. The remote 3rd party api will get refreshed…but my local one will not. I have to close the window and re-open the page to see the new data.

I am assuming i need to set something special in my worker in the response, but not sure what that is, (no-cache, no-storage ?) I have played with things but not seeming to get things workers. Is this an issue with using fetch on .dev and can be controlled when i move things to my own domain? I’m sure this is basic…but its a serious roadblock for me…going on 2 days racking my head.

Thank you.

the fetch() method hits Cache API as if you never had a worker so if your origin server includes a cache-control header you will be in trouble if assume each fetch() is guaranteed to make an IP connection to origin. see Bypassing Cloudflare Cache - #13 by yw662

the origin server is the same worker project. So i am referencing from the front-end a fetch to (’/somepath/’) that is within my worker.

Can you suggest what would be the proper response from the worker when sending back data? Is this in my control on workerpath.dev ?

Thanks

This isn’t working:

fetch('/api/show_quotes/cus_' + newstuff.id + "/" + Date.now(),
{
  method: 'GET',
  cache: 'no-store'
}

But the cache: ‘no-store’ isn’t being respected, but what did seem to get respected is setting the headers via:

var myHeaders = new Headers();
myHeaders.set('Accept', 'application/json');
myHeaders.set('Content-Type', 'application/json');
myHeaders.set('Cache-Control', 'no-store');
myHeaders.set('Pragma', 'no-store');
var myInit = {
  method: 'GET',
  headers: myHeaders,
  cache: "no-store"
};

then:

fetch('/api/show_quotes/cus_' + newstuff.id + "/" + Date.now(), myInit)

In my experience the worker always come first (after the firewall, anyway), before CF cache and before origin server, and there is no cache for workers.dev.

I would suggest check F12->Network first. There are many possibilities. Browser may cache the data, and there might be a service worker. A (wrongly implemented) service worker may cause some issues like that.