Why Redis exists in Web3 systems
How direct IPFS gateway lookups cause massive latencies, and why caching immutable CIDs in Redis drops feed render times to 80ms.

Decentralized storage solutions (like IPFS, Arweave, and Filecoin) are great for censorship-resistance, but they are terrible for real-time latency.
When Socio3 V2 loaded a user's feed, it had to fetch the metadata JSON file for every post:
- Read the IPFS hash from the blockchain (
QmMetadata...). - Request the file from Pinata's IPFS gateway:
gateway.pinata.cloudtext
- Wait. And wait.
On average, a public IPFS gateway takes 3 to 5 seconds to locate, fetch, and return a single pinned JSON file. If your home feed displays 15 posts, your app is forced to execute 15 parallel network queries, freezing feed rendering for several seconds.
This is why we introduced Upstash Redis as our backend caching layer.
1. The Gateway Latency Problem
IPFS is a peer-to-peer network. When you query a gateway for a file CID:
- The gateway must search the Distributed Hash Table (DHT) to locate nodes pinning that specific file.
- It establishes connections, downloads block fragments, verifies hashes, and streams the payload.
- Even with private Pinata gateways, cold-start retrieval times are rarely under 1.5 seconds.
2. Caching Immutable Content (The Web3 Cheat Code)
In standard Web2 databases (like PostgreSQL), caching is notoriously difficult because data is mutable (it changes). You must implement complex cache invalidation rules when records update.
In Web3, IPFS storage is immutable (content-addressed). The content of a CID hash can never change:
This means we can cache IPFS metadata in Redis forever (or with a high TTL) without worrying about data drift or cache invalidation.
3. Implementing the Redis Cache Proxy
In Socio3, we routes all metadata requests through a cached backend Express proxy endpoint (GET /api/ipfs/:hash):
4. The Performance Impact
By wrapping Pinata's gateway with Upstash Redis, the feed load time dropped from 4,200ms to 80ms—a 98% decrease in latency.
Never let your client-side React app fetch IPFS CIDs directly from public gateways. Set up a cached proxy endpoint on your API server. It protects your Pinata gateway credentials, speeds up user load times, and saves backend resource costs.
If IPFS CIDs are immutable, why do we set a 7-day TTL instead of caching them permanently (forever) in Redis? Hint: Think about memory limits and database maintenance costs.
Was this lesson helpful?
Let us know what you think of this specification. (submitting anonymously)
