Closed josephmturner closed 4 months ago
It might be good to add a custom header or querystring to say "delete only cache and not delete the file" or have DELETE
on non-writables be a cache clear by default
Also maybe we could use the 'Cache-Control' header? https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
Maybe we could have new values for it or reuse them.
Also could consider new HTTP methods (was done before) but that means clients like Godot might have trouble: https://github.com/godotengine/godot/blob/master/core/io/http_client.h#L118
Yeah, e.g. a HEAD request with Cache-Control: no-cache, no-store
could be used to tell the server, "Don't give me the content of this file, just stop caching it locally."
Aslo related to #67
Also, see https://github.com/RangerMauve/hypercore-fetch/tree/e886eb06a8da88d2644df4dc62cdd55fe11b4894#fetchhypernameexampletxt-method-delete-headers-x-clear-cache for the precedent for how hypercore-fetch 8 did this.
IIUC, the new drive.clear() command does exactly this: https://github.com/holepunchto/hyperdrive-next/pull/45
Yeah, e.g. a HEAD request with
Cache-Control: no-cache, no-store
could be used to tell the server, "Don't give me the content of this file, just stop caching it locally."
I suggest that we use Cache-Control: no-store
.
"Note that no-cache does not mean "don't cache". no-cache allows caches to store a response but requires them to revalidate it before reuse. If the sense of "don't cache" that you want is actually "don't store", then no-store is the directive to use." (from https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#no-cache)
I'm not sure whether it makes more sense to use a HEAD
or DELETE
request. DELETE
seems more semantic, but AFAICT, the Cache-Control
header is not normally used with DELETE
.
@RangerMauve what do you think about using HEAD Cache-Control: no-store
? Could we make this work recursively on directories?
Since my last comment, I think we settled on DELETE Cache-Control: no-store
. Does drive.clear()
work recursively on directories?
Regardless, it could be a nice API if DELETE Cache-Control: no-store
on the root URL, i.e., hyperdrive://PUBLIC-KEY/
called drive.clearAll()
. WDYT?
I think in both cases, it's fine to leave the default options
arg as { diff: false }
.
DELETE to the root is now a drive.purge, the cache control thing is a TODO for now
Added in https://git.sr.ht/~ushin/hypercore-fetch-ushin/commit/6856a5f. Thank you!
It should be possible to send a request to
hyper-gateway
which deletes locally-stored copies of a particular hyperdrive file. Users should be able to perform this kind of deletion on files in hyperdrives which are not writable.I don't see a command in the hyperdrive API which does this, though...