Every call you do not repeat is a call you do not pay for. Deterministic calculations are safe to cache forever. This guide shows what to cache, what not to, and how to key it.
A common worry when you scale a spiritual app is that the API bill grows linearly with daily active users: more users, more horoscopes, more charts, more calls. It does not have to. Most of what RoxyAPI returns is deterministic, meaning the same input always produces the same output, so you only ever need to compute it once. Cache those results in your own store and your bill flattens while your traffic keeps climbing.
Two facts shape the strategy:
Every call that reaches the API counts toward your monthly quota, 4xx errors included (a 429 rate-limit answer and a 5xx failure on our side are the exceptions), so validate inputs before you send them and never retry a 4xx unchanged. A call answered from your own cache never reaches the API and costs nothing.
Data responses are not edge-cacheable. RoxyAPI sends private, no-store on /api/v2/* responses so a CDN will not transparently cache them. The cache that saves you money is the one you run, keyed by the request inputs.
What is safe to cache forever
A result is permanently cacheable when nothing in the answer depends on the current date or time. Same inputs, same answer, for years. Cache these in your own Redis, database, or KV with no expiry and key them by the request body or path parameters.
Endpoint class
Why it is stable
Suggested key
Natal birth chart
Fixed birth date, time, and place never change
hash of date + time + lat + long + house system
Numerology (Life Path, Expression)
Derived from a name and birth date
name + birthdate + system
Vedic kundli, Navamsa, Dasha sequence
Computed from immutable birth data
birth data hash
Panchang for a specific date and place
A past or fixed date is fixed
date + lat + long
I-Ching hexagram by number, tarot card by id
Static reference content
the id
Because the inputs are immutable, a cache hit here is correctness-neutral: you are returning the exact bytes the API would have returned.
What to cache briefly or not at all
Time-sensitive endpoints change with the clock. Cache them with a short TTL that matches their natural cadence, keyed by the date, or skip the cache entirely for live data.
Do not cache a daily horoscope under a key that ignores the date. Include the date in the key (leo:2026-05-23) so each day computes once and serves from cache for the rest of that day.
Endpoint class
Cadence
Strategy
Daily / weekly / monthly horoscope
Changes per day or week
Cache with the date in the key, expire at end of the period
Current transits, current dasha
Changes continuously
Short TTL (minutes to hours) or live
Random tarot draw, coin-cast I-Ching
Intentionally non-deterministic
Never cache; randomness is the feature
How to key a cache entry
The rule is simple: the cache key must contain every input that changes the output, and nothing that does not. For coordinate-dependent endpoints, that is the resolved birth data plus any options like house system or ayanamsa. Resolve the location once (see the location lookup) and store the resolved coordinates so the same city does not re-geocode on every request.
ts
import { createHash } from "node:crypto";
import { createRoxy, type PostAstrologyNatalChartData } from "@roxyapi/sdk";
import Redis from "ioredis";
const roxy = createRoxy(process.env.ROXY_API_KEY!);
const redis = new Redis();
type ChartInput = NonNullable<PostAstrologyNatalChartData["body"]>;
function chartKey(input: Record<string, unknown>) {
const json = JSON.stringify(input, Object.keys(input).sort());
return "chart:" + createHash("sha256").update(json).digest("hex");
}
async function getChart(input: ChartInput) {
const key = chartKey(input);
const hit = await redis.get(key);
if (hit) return JSON.parse(hit); // no billable call
const { data, error } = await roxy.astrology.generateNatalChart({ body: input });
if (error) throw error; // never cache a failure
await redis.set(key, JSON.stringify(data)); // immutable, no expiry
return data;
}
python
import hashlib, json
def chart_key(payload: dict) -> str:
blob = json.dumps(payload, sort_keys=True)
return "chart:" + hashlib.sha256(blob.encode()).hexdigest()
def get_chart(payload: dict):
key = chart_key(payload)
hit = r.get(key)
if hit:
return json.loads(hit) # no billable call
res = roxy.astrology.generate_natal_chart(**payload) # date, time, latitude, longitude, timezone
r.set(key, json.dumps(res)) # immutable, no expiry
return res
How much does this save?
For a horoscope feature, the savings are dramatic because reads cluster. Twelve signs times one daily compute is twelve calls per day, no matter whether ten users or ten thousand read them.
12 calls/day
A whole-app daily horoscope feed for all twelve signs, regardless of how many users read it, when you cache by sign and date. Without caching, the same feed scales with every page view.
FAQ
Does RoxyAPI cache responses for me?
Data API responses are sent as private and no-store, so a CDN will not cache them transparently. Run your own application cache keyed by the request inputs to avoid repeat billable calls.
Do cached calls still count toward my quota?
Only calls that actually reach the API count, and each one counts whether it succeeds or fails with a 4xx, apart from a 429 rate-limit answer. A request that fails on our side with a 5xx does not count, so retrying it is free. A hit in your own cache makes no request, so it costs nothing against your quota.
Which RoxyAPI results are safe to cache forever?
Anything computed from immutable inputs: natal charts, numerology from a name and birth date, kundli and dasha, and panchang for a fixed date. Their output never changes, so an unbounded cache is correctness-neutral.
How should I cache a daily horoscope?
Cache it with the date and sign in the key and expire it at the end of the day. That computes each sign once per day and serves every reader from cache.
Next steps
Pair caching with the right plan for your volume on the pricing page, and see structured outputs for how owning your interpretation layer reduces calls further.
R
RosieYour AI guide to RoxyAPI
R
Hi, I am Rosie, your guide to the RoxyAPI insight tools.
Ask me to read your birth chart, pull a card, or map your numbers, and I will interpret what it means for you. Unlike most AIs, I never make the numbers up: every reading runs on real, verified calculations. Curious about the API, pricing, or docs instead? Ask me that too.