Adaptive TTL Cache Invalidation & force_refresh Semantics
Long-lived cross-tenant caches unlock 100% repeat gross margin—but only if callers can bypass stale entries cleanly without letting upstream errors destroy valid history. FuelRouter implements deterministic adaptive TTL and atomic force_refresh semantics via steel_core_4/archive_cache.py.
Adaptive TTL & Cache Invalidation State Transitions
| Event | Read Cache? | TTL Multiplier | Cache Mutation Rule |
|---|---|---|---|
| Normal Hit (within TTL) | Yes (0 upstream calls) | Unchanged | Increment hit count; bill 100% new-tenant / 10% repeat |
| force_refresh: true -> Identical Payload | Bypassed | 1.5x (capped at 21d-30d) | Atomically update timestamp & extend adaptive TTL |
| force_refresh: true -> Changed Payload | Bypassed | 0.5x (floored at 7d) | Atomically replace payload & shorten TTL for volatile target |
| force_refresh: true -> Explicit Empty | Bypassed | Invalidated | Evict stale entry so callers do not read deleted entities |
| force_refresh: true -> Upstream 503/Fake-200 | Bypassed | Preserved | Never poison or overwrite prior verified archive record |
Self-Tuning Volatility Detection Across 7d-30d Bounds
Not all URLs or queries mutate at the same cadence. A static API reference page may stay identical for months, while a SaaS pricing table updates every two weeks. FuelRouter hashes every refreshed payload against the archived digest.
Unchanged payloads expand TTL by 1.5x up to max_ttl_s (1,814,400s on web_search and clean_scrape_extract; 2,592,000s on ai_chat_json, embeddings_rerank, and b2b_domain_dns_enrichment). Mutated payloads shrink TTL by 0.5x down to min_ttl_s (604,800s).
Safe Live Refresh Under Partial Upstream Outages
When a caller passes force_refresh: true, FuelRouter skips the archive read path and routes live across ranked upstreams. If the live refresh succeeds and passes the Anti-Fake-200 gate, SQLite WAL atomically replaces the archive entry.
If all upstreams fail during a force_refresh, the caller receives an unbilled HTTP 503 ($0.00) while the prior verified archive entry remains uncorrupted.
Force a Live Refresh and Atomically Update the Archive Cache
curl -fsSL -X POST "https://fuelrouter.fastmesh.dev/v1/router/dispatch" \
-H "Content-Type: application/json" \
-d '{
"pool_id": "clean_scrape_extract",
"tenant_id": "pricing_monitor",
"inputs": {"url": "https://example.com/pricing", "format": "markdown"},
"force_refresh": true,
"max_cost_micros": 60000
}'
Cache Freshness & Invalidation Best Practices
- Default to force_refresh: false for research, enrichment, and embedding pipelines to maximize 100% repeat margin.
- Reserve force_refresh: true for scheduled drift monitors and explicit user 're-fetch live' actions.
- Verify POST /v1/router/quote with force_refresh: true reports cache_would_hit: false and shows the live upstream plan.
- Trust explicit empty invalidation to clear deleted pages without letting 503 glitches wipe good data.
Frequently Asked Technical Questions
Does force_refresh: true still enforce Anti-Fake-200 and SSRF checks?
Yes. Every live refresh executes the full SSRF guard, failover pipeline, and 5-stage Anti-Fake-200 gate.
What is the shortest possible adaptive TTL after repeated content drift?
The global floor min_pool_ttl_s is 604,800 seconds (7 days), though callers can always bypass reads on demand via force_refresh: true.
If force_refresh fails with HTTP 503, am I charged?
No. Exhausted force_refresh calls bill strictly $0.00 (charged_micros: 0).
Live Try-Now Console & Machine Discovery
Test failover routing, dry-run quotes, and circuit breaker metrics on the live gateway or connect via JSON-RPC 2.0 MCP.
Related FuelRouter Architecture Guides
- Prepaid Creem Credit Packs & HMAC-SHA256 Webhook Settlement — prepaid API credit packs HMAC-SHA256 webhook idempotency
- Zero Customer Trace Resale & Enterprise Privacy Architecture — zero customer trace resale privacy API failover gateway
- Deterministic prefer & exclude Upstream Routing Overrides — prefer and exclude deterministic upstream API routing policy