I know This question might have been asked many times, but i’d appreciate the answer in 2021 too.
Basically, I use ipfs-desktop on mac. Then , I add it as ipfs add filename.txt
Then i check it on myowngateway.com/ipfs/cid and also on ipfs.io/ipfs/cid
As it turns out, myowngateway.com is so slow that 98% of the time, it never resolves to a file and just returns 504 timed out. As for the ipfs.io , 85-90% of the time, it resolves to a file somehow quickly(sometimes takes 5 min too), but sometimes it just never resolves and hangs indefinatelly.
After I do ipfs add filename.txt, I also check on another computer this command: ipfs cat cid and it turns out this is super fast , immediatelly returns the file…
Question 1: How can I make sure that my gateway is fast and not this slow (as in never resolving to a file). Note that if ipfs.io gateway loads the file, then my gateway also starts loading it instantly.
Question 2: If I don’t use gateway, is there any chance that i can do ipfs fetch from javascript ? I know that ipfs cat is a terminal command, but anything like this from javascript and still not using gateway ?
You don’t need to think something like “I need to fetch data from computer A “. In IPFS, data stores in which computer doesn’t matter and you just need think “I want to this file in IPFS and I don’t care where the data store.”
I agree, but I don’t want computerB to start a node. This is because computerB is a front-end app running in browser. So i need to make a call and get the file somehow. Since gateways are too slow,
I am looking for the alternatives.
I think there is not a way can offer quick fetch files neither gateway or IPFS-node in browser.
Gateway node will cache the file, so after first loading the latter fetch should be quick.
Sorry I’m not native English speaker. I mean if you want the “fast first loading”. The gateway and In browser IPFS node are both not suited for you. Because they both need time to search the file in DHT network.
However, if you use gateway, when first user visits a file from the gateway, that gateway will cache the file. So that, when second people visits the same file, gateway doesn’t need search file again and it can just return file and that’ll be quick.
Did you just close your local node after uploading the file? Other IPFS nodes won’t save your files automatically, unless they get your files.
I think the best way to offer quick files fetch is saving files to your gateway node. Basically, it’s a traditional Client-Server model. However, it also provides a IPFS cid that users can visit or pin use IPFS node.