With the latest collection changes in blockstack.js, we came across some caching related issues which saw stale data being returned from a getFile request. One potential solution is to set the Cache: no-cache header.
@yknl Can you give me some more detail on the collection changes that caused these issues?
@zone117x and I think that the cache-control directive needs to be set in the server's responses, rather than client side, since the specifying it as a header causes a CORS error, and specifying it as a fetch option doesn't seem to do anything (the browser likely just ignores it to avoid showing the CORS error)
How do you recommend we go about doing that since the Gaia hub is not involved on the read requests.
The gaia hub has a config option for cache-control that all of the backend drivers currently support. E.g. the Azure blob upload function can specify a cache-control response header.
The PBC hub currently has this set to public, max-age=1, which is a strange cache configuration, and seems to explain the flakiness during testing.
There does not appear to be a reasonable client-side way to override this, due to the CORs simple requests rules -- note the lack of any cache headers in the CORs GET request safelist.
There are some hacky cache-busting techniques, like appending a ?nope=${Date.now()} to the GET request URL, but I think we should first explore the PBC hub cache config setup first.
@wileyj suggests we get feedback from @kantai on why we are currently using this cache config.
@reedrosenbluth @yknl the staging hub https://collection-hub.blockstack.org now has the cache-control: no-cache response header. You should see the header for newly updated files.
I did some preliminary testing with my own sample app, and an unmodified blockstack.js. Chrome's network devtools show the response payload sizes which indicate that the caching is working as intended.

@reedrosenbluth Can you test if the caching bug is fixed in the collections sample app when using the staging hub?
The contacts app's cache behavior appears to be working great with the newly updated collections staging hub. Response headers contain the no-cache directive and no stale data is being presented 馃槃
I am still experiencing this for https://gaia.blockstack.org//hub/xxx. The header is still cache-control | public, max-age=1
Most helpful comment
The gaia hub has a config option for
cache-controlthat all of the backend drivers currently support. E.g. the Azure blob upload function can specify acache-controlresponse header.The PBC hub currently has this set to
public, max-age=1, which is a strange cache configuration, and seems to explain the flakiness during testing.There does not appear to be a reasonable client-side way to override this, due to the CORs
simple requestsrules -- note the lack of anycacheheaders in the CORs GET request safelist.There are some hacky cache-busting techniques, like appending a
?nope=${Date.now()}to the GET request URL, but I think we should first explore the PBC hub cache config setup first.@wileyj suggests we get feedback from @kantai on why we are currently using this cache config.