Redis …Embedding model …SerpApi …Gemini off
Under the hood

Every SerpApi call, cache decision and credit, live.

Each lookup is an exact Redis hit, a semantic hit, or a SerpApi call that costs one credit. Run it twice: the second run is free.

try:
The cache

How a query decides whether to spend a credit

Every SerpApi request goes through serpapi_cache: a drop-in replacement for serpapi.Client.search(). Similar questions reuse answers; different doses never do.

1 · Normalize

Lowercase, collapse spaces, glue units to numbers.

"Dolo 650 MG" → "dolo 650mg"
2 · Exact key

SHA-256 of the params. One Redis GET, no model: under 5 ms.

seen before → EXACT HIT
3 · Embed + compare

MiniLM turns the query into 384 numbers; cosine similarity against every cached query.

"stamlo 5 tablet" ≈ "stamlo 5" 0.917
4 · Dosage guard

Close meaning but different numbers? Never reuse. A wrong dose is worse than a credit.

"Dolo 500" vs "Dolo 650" 0.949 → blocked
5 · SerpApi

Only now is a credit spent. The result is written to Redis on a background thread, so the user never waits for it.

miss → 1 credit, cached 24 h
Redis, persistent
Survives restarts (AOF), shared by every process, native TTL: prices 24 h, product links 24 h, Gemini decisions 30 days.
Product links: exact only
Page-token lookups have no text to compare, so they can only hit on the exact same token. This fixed a bug where every link returned the first product.
Fails safe
Redis down? The cache switches to passthrough: searches still work, they just cost credits. Nothing crashes.
Cache lab · 0 credits

Ask the cache what it would do

Type any query. It runs the same decision on the live Redis contents and shows the nearest cached queries with their similarity scores. Nothing is sent to SerpApi.

Redis

What is cached right now

Raw SerpApi responses, product-page lookups and Gemini spelling decisions, each with its own TTL.

cached querytypeexpires in
Proof

What the cache has saved since this server started

Every number is measured from real calls on this machine, not estimated from a formula.

Searches
0
SerpApi requests
0
Credits spent
0
Credits saved
0
Avg latency
—
cache hit
Waiting saved
—
0 entries in Redis