On this page
An IPFS link and an HTTPS gateway URL can refer to the same content, but they work differently. The IPFS address identifies content without naming a particular web server; the gateway URL asks a specific service to retrieve and deliver it. This comparison explains how to share both, what a gateway adds, and how to check links without mistaking retrieval for verification.
Key Takeaways
- A content identifier (CID) identifies content in IPFS. An
ipfs://address combines a CID with an optional path. - An HTTPS gateway URL includes a gateway hostname as well as the CID and path. The gateway is the service your browser contacts.
- Two gateway links can point to the same CID and path without either gateway being available or trustworthy.
- Comparing downloaded files checks whether the gateways returned the same bytes; it does not prove those bytes correspond to the intended CID.
- Browser support for
ipfs://depends on the browser and its configuration. HTTPS gateway links are generally easier to open in ordinary browsers.
CID, IPFS address, and gateway URL
The following examples use placeholders, not a real CID or operational gateways. Replace <CID> with an actual CID and the .example hostnames with gateways you intend to use.
| Form | Fictional example | What it identifies or selects |
|---|---|---|
| CID | <CID> | An IPFS content identifier. |
| IPFS address | ipfs://<CID>/report.pdf | The item at report.pdf under the content identified by the CID. |
| Gateway URL | https://gateway-a.example/ipfs/<CID>/report.pdf | The same requested CID and path, accessed through gateway A. |
| Another gateway URL | https://gateway-b.example/ipfs/<CID>/report.pdf | The same requested CID and path, accessed through gateway B. |
A CID is not a gateway hostname or a conventional filename. It contains information used to identify content, typically through a cryptographic hash. When the CID identifies a directory-like structure, the path selects an item within it. Changing the CID or the path can select different content.
The gateway host, by contrast, identifies where an HTTPS request is sent. It is not part of the IPFS content identity. Gateway URL formats and supported features can vary, so check the chosen operator's instructions before constructing a link.
Research limitation: Official IPFS documentation was not available to consult for this article. Check the current IPFS documentation and the gateway operator's documentation for URI syntax, gateway formats, and browser support before relying on a particular setup.
Advertisement
IPFS link vs gateway URL: practical differences
| Consideration | ipfs:// address | HTTPS gateway URL |
|---|---|---|
| Portability | Names the CID and path without choosing a gateway in the address. The recipient still needs an IPFS-capable way to retrieve it. | Names a particular gateway. Recipients depend on that service unless they change the link or use another retrieval method. |
| Browser access | Depends on browser capabilities, extensions, or local configuration. Do not assume a recipient can open it directly. | Uses ordinary HTTPS, so it is generally easier to open in a browser, subject to the gateway and content being reachable. |
| Trust and privacy | Retrieval still depends on the software and infrastructure used. | The gateway can see the request and may return incorrect content. HTTPS protects the connection to that gateway; it does not independently prove the response matches the CID. |
| Availability | A CID does not ensure anyone is serving the content. | A gateway may be down, restrict a request, or be unable to retrieve the content. |
For a broad audience, share a working gateway link for convenience and include the ipfs:// address or CID and path separately. That gives recipients an alternative if the chosen gateway fails and lets IPFS-capable users choose their own retrieval method. Neither form guarantees that content remains available: arrange appropriate storage or pinning and check availability over time.
Treat the CID as an identifier, not a confidentiality control. Do not publish sensitive material merely because it is addressed through IPFS. A gateway may also learn which content a visitor requests; avoid putting credentials or private information in shared URLs.
Check two gateway links safely
First, compare the links themselves. For the path-style examples above, check that both contain the same intended CID and path after /ipfs/. Also inspect query parameters and fragments: differences can affect how a link is interpreted or displayed, and a fragment is not sent as part of the HTTP request. A visual comparison alone does not prove what either server will return.
Next, retrieve the content from gateways you have chosen and compare the resulting bytes. The following Bash script is for a small, non-sensitive file on a Unix-like system with curl, cmp, sha256sum, and mktemp. It does not automatically follow redirects. It accepts only HTTPS URLs, but it does not validate hostnames or make arbitrary URLs safe to fetch. Run it only with links you trust in an environment where those network requests are authorized. Use a disk quota or another appropriate resource limit; the time limit below is not a download-size limit.
Save it as compare-gateways.sh and run bash compare-gateways.sh 'FIRST_HTTPS_URL' 'SECOND_HTTPS_URL', replacing the arguments with your links. The code has not been executed for this article.
#!/usr/bin/env bash
set -eu
if [ "$#" -ne 2 ]; then
echo "Usage: bash compare-gateways.sh FIRST_HTTPS_URL SECOND_HTTPS_URL" >&2
exit 2
fi
workdir=$(mktemp -d)
trap 'rm -rf -- "$workdir"' EXIT
fetch() {
url=$1
output=$2
case "$url" in
https://*) ;;
*) echo "Only HTTPS URLs are accepted." >&2; return 1 ;;
esac
if ! status=$(curl -q --proto '=https' --silent --show-error \
--max-time 30 --output "$output" --write-out '%{http_code}' -- "$url"); then
echo "Request failed." >&2
return 1
fi
if [ "$status" != 200 ]; then
echo "Unexpected HTTP status: $status" >&2
return 1
fi
}
fetch "$1" "$workdir/first"
fetch "$2" "$workdir/second"
sha256sum "$workdir/first" "$workdir/second"
if cmp -s "$workdir/first" "$workdir/second"; then
echo "The downloaded files have identical bytes."
else
echo "The downloaded files differ." >&2
exit 1
fi
A redirect produces a non-200 status and stops the script. If you encounter one, inspect its destination and decide whether to trust it before making a separate request. On systems without sha256sum, use an equivalent local SHA-256 utility or remove that line; cmp performs the byte comparison.
What the comparison proves—and what it does not
- Matching bytes mean the two downloads are identical. Both gateways could still have returned the same incorrect file or error content with a successful status.
- Different bytes mean the responses differ. Recheck the CID, path, and gateway behavior before drawing conclusions about the cause.
- A trusted, independently obtained file digest can be compared with the downloaded file's SHA-256 digest. The digest must come from a source you trust to describe the intended file.
- To check content against the CID itself, use an IPFS implementation or verification workflow that validates the retrieved blocks and the path against the expected CID. A CID is not necessarily the plain SHA-256 digest of the downloaded file: IPFS content can be represented as a graph of blocks. Confirm the verification behavior of the software you use.
Even successful CID verification establishes correspondence to the expected content identifier, not the identity or authority of the person who gave you that identifier. Obtain the expected CID through a trusted channel when authenticity matters.
Advertisement
Common Mistakes
- Treating a gateway hostname as part of the content identity. Changing gateways changes the service contacted, not necessarily the requested CID and path.
- Assuming a CID guarantees availability. Content must still be obtainable from somewhere; a gateway cannot guarantee retrieval.
- Assuming HTTPS verifies IPFS content. HTTPS authenticates the connection to the named host, not the relationship between its response and the CID.
- Comparing a file's SHA-256 directly to the CID without understanding its representation. Use an appropriate IPFS verification workflow or an independently trusted file digest instead.
- Sharing only a gateway URL for a long-lived reference. Include the CID and path so readers can use another retrieval method if needed.
Best Practices
Record the CID and exact path alongside a human-readable description of the content. Provide an HTTPS gateway link for convenience, but avoid presenting a particular gateway as the only source. For important research artifacts, keep an independently distributed digest or use a verified IPFS retrieval workflow, and maintain an availability plan.
If you operate software that fetches user-supplied gateway URLs, do not copy the comparison script into a server as a security boundary. Validate destinations and redirects, restrict network egress, and apply time and resource limits appropriate to the service.
Conclusion
Use an ipfs:// address to communicate the content identifier and path without committing to one gateway. Use an HTTPS gateway URL when recipients need a convenient browser link. Test retrieval separately from integrity, and obtain the expected CID or file digest through a trusted channel.
What would your domain sell for?
A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.