How does IPFS work offline?

I don’t exactly understand when it says “IPFS works offline”. Can anyone elaborate for me?

Where are you getting the quote that “IPFS works offline”? I’d be interested to know the context.

There are two ways I’m aware of that it works offline.

  1. If you’ve accessed a piece of content over IPFS and it’s still cached on your node, you can access it exactly the same way as before with no network connection

  2. If you have a subset of IPFS nodes that can connect to each other but not to the Internet, IPFS will still work

1 Like

It’s in the whitepaper of Filecoin.

IPFS has proven the utility of content-addressing by decentralizing the web itself, serving billions of files used across a global peer-to-peer network. It liberates data from silos, survives network partitions, works offline, routes around censorship, and gives permanence to digital information.

Could you elaborate the second point? What are possible ways to connect without the Internet?

An example would be computers on a LAN. They don’t require a connection to the Internet in order for IPFS to work between them. Another example could be computers in a mesh network that doesn’t have a connection to the Internet.

How does an ipfs mesh network work? I can’t find anything about it. It would need different bootstrap servers, and a local DHT I would think. I didn’t know that it was possible.

Mesh networks aren’t specific to IPFS (example). The general theme is that don’t rely on centralized ISPs and instead rely more on P2P connections. Even in more traditional networks if someone disables connections leaving a country to the larger internet but the computers within the country can communicate with each, I think it could be said that those computers within the country are offline in a sense.

Any node can act as a bootstrap node. If something is added to save peers you’ve seen before as potential bootstrap servers for later (which I think I’ve seen an open issue for) instead of relying on the ones hosted by Protocol Labs, then nodes wouldn’t even necessarily need access to the default bootstrap nodes and things would be more likely to automatically keep working. Otherwise, users would need to manually point to an ad-hoc bootstrap node they can reach.

1 Like

Thanks! That makes more sense. That save peers thing sounds good, do you have a link? It seems it would be very useful for that to be enabled by default on nodes.

Agreed! Here’s the GitHub issue for it: https://github.com/ipfs/go-ipfs/issues/3926.

It might not be what the document writer meant, but I also imagine it to mean that if you create a site or file and add it to ipfs, and other nodes host it, then it will remain available even when the originating node is offline, so long as at least one other node continues to host it during that time.

Thanks! I was thinking, if I was running an offline mesh network, and could just redirect all bootstrap node requests to redirect to my local node I’m using for bootstrapping the mesh. A bit hacky, but it should work.

You can just add the local address of your node as a bootstrap node address in the config file.

Hello People, I am new to IPFS and building my KB. One question, is network connectivity needed for IPFS to work?

Dear, IPFS enthusiasts

As stated by @leerspace if you have accessed a piece of content over IPFS and it’s still cached on your node, you can access it exactly the same way as before with no network connection. This is also shown in this video on Youtube https://www.youtube.com/watch?v=pQNZZIzLYbI at timestamp 7:45 with the distributed wikipedia example.

1.However, I have tried to access multiple IPFS websites but after visiting it and turning of the wifi I could not visit the webpage anymore. For example the distributed Wikipedia that can be visited on

https://en.wikipedia-on-ipfs.org/wiki/ and will redirect you to your local host if you have IPFS installed.

After visiting the homepage, I switched off the wifi and when reloading the page I got this error message

   ipfs resolve -r /ipns/en.wikipedia-on-ipfs.org/wiki/: could not resolve name
  1. Thus, I could not visit the distributed Wikipedia offline. My question is what goes wrong here? I tried it in Firefox and Chrome with ipfs companion extension implemented.

  2. If I use ipfs companion and copy the CID and/or pin it from an IPFS webpage and after load it locally via

    localhost:8080/ipfs/CID       or via a gateway      ipfs.io/ipfs/CID
    

Then I only receive the HTML code in the browser but it does not load the CSS nor the images. Hence the CID does not represent the root folder of the particular page I am visiting. For example the distributed Wikipedia home page is represented by the CID: QmehSxmTPRCr85Xjgzjut6uWQihoTfqg9VVihJ892bmZCp. Then visiting it via

 localhost:8080/ipfs/QmehSxmTPRCr85Xjgzjut6uWQihoTfqg9VVihJ892bmZCp

Does not give me all the content it should give me compared to the original distributed Wikipedia homepage. What should I do to have the full webpage loaded locally in my browser.

  1. How can I access my ipfs cache folder to see which web content I am currently caching and hence host to other users.

Thank you in advance!

When you import a web page via IPFS companion, it only pulls in the HTML. The images can be imported separately. However, the web page has anchor links that utilize a particular directory structure. In order to view the web page in its original formatting, you’ll need to recreate the MFS directory structure the HTML uses.

For example, the image of Bill English is located at /I/m/Bill_English_September_2016.jpg … However, the imported image will not be placed at that location within your local IPFS node. The imported image can be viewed locally without any connection to the Internet, but will not be displayed in the HTML page, because it’s not at the location indicated in the the HTML.

Additional Related:

Github Issue #94 (Open)

https://github.com/ipfs/in-web-browsers/issues/94

But the question was related to a previously imported web site that browses correctly when online, but is missing content when offline. I suspect that ipns is used in the references and that name is not resolving when offline to get the remainder of the content.