I want to make sure some data is cached on a node without having to download it. However, I do not want to pin it. How would I do this?
E.g. I have a large file that I know I am going to need soon, but I do not yet need right now. How can I tell an ipfs node that the file should be preloaded?
I can see two ways to do this, but both seem to be inefficient and non-elegant to me:
- IPFS get and discard the result
- IPFS pin followed by unpin
Is there a nicer way?
The nicer way would be to use the gateway.
So if you call https://siderus.io/ipfs/$CID (where $CID is your hash/cid) the gateway will cache it for you for some time (depends on the GC settings, Siderus has it disabled for now).
The same works with other gateways, but I am not sure about garbage collector for the other services. You should be able to do it as well on https://ipfs.io/ipfs/$CID.
I guess I should have added that this is a private swarm, and it needs to be cached on the local node.
I can of course do a get request to the local gateway and then discard the result. E.g. curl http://localhost:8080/ipfs/$CID . The next question then would be if I have to download everything and pipe it to /dev/null, or if closing the connection is safe.
E.g. you have a large video that you want to preload. Do you have to wait for completion of the request, or can you close the connection?
pin then unpin seems like the “right” way. In fact, to be safe you should probably pin, then not unpin until after you’re done using the file.