Back to Prompts
Coding Assistant

API Response Caching

For apps that depend on external APIs From the Caching AI Coding Building Block.

Prompt
My app calls external APIs like [payment gateway / weather service / social media API] and I'm hitting rate limits and adding unnecessary latency.

Set up an API response caching layer that:
- Caches responses based on the request URL + parameters
- Respects the API's Cache-Control headers when available
- Falls back to a configurable TTL when no cache headers exist
- Serves stale cache if the external API is down (stale-while-revalidate)
- Tracks cache hit rate and average response time saved

My stack: [your framework and language here]

I'm learning, so explain each part simply.
4 views 0 copies