HouseMuslim
Concepts

Caching & Limits

How the public API caches deterministic responses, coordinate quantization, ETag support, and rate limiting.

All computation endpoints are deterministic and stateless, so they are safe to cache aggressively.

Cache headers

Successful GET responses include:

Cache-Control: public, max-age=86400, stale-while-revalidate=86400
ETag: "f772776d6f178fd3c164ad2cbb5430b8b83e6a7a"

Send If-None-Match with a previously returned ETag to get a fast 304 Not Modified:

curl -H 'If-None-Match: "f7727..."' \
  "https://api.housemuslim.org/api/v1/prayer/times?lat=-6.2&lng=106.8"

Coordinate quantization

To maximize cache hit-rate, the cache key quantizes coordinates:

  • lat / lng → 3 decimals (~110 m grid)
  • elevation → nearest 50 m

Two requests within the same ~110 m cell share one cached result. The computation itself still uses the exact precision you pass.

A daily bucket is included in the cache key, so "today" requests (no explicit date) roll over automatically each day.

Rate limiting

A global per-IP rate limit applies. Heavier endpoints (/prayer/times/month, /calendar/islamic, /events, /ramadan/schedule) have a stricter bucket. Exceeding it returns 429 Too Many Requests.

Validation

Inputs are validated before any computation:

  • lat ∈ [−90, 90], lng ∈ [−180, 180]; NaN/Inf rejected
  • elevation ∈ [−500, 9000] m
  • Hijri hy ∈ [1, 3000], hm ∈ [1, 12], hd ∈ [1, 30]
  • Date ranges bounded to prevent oversized payloads

Invalid input returns 422 Unprocessable Entity.

On this page