@upendra.manike/cacheable-fetch
v1.0.6
Published
Offline-first API Layer for JavaScript/TypeScript - Wrap fetch with automatic localStorage/IndexedDB caching, TTL, and background refresh. Perfect for PWAs, mobile web apps, and offline-first applications. Reduce server load and improve user experience.
Maintainers
Keywords
Readme
cacheable-fetch
Offline-first API Layer - Wrap fetch with automatic localStorage/IndexedDB caching, TTL, and background refresh.
Installation
npm install @upendra.manike/cacheable-fetchUsage
import { cacheableFetch } from '@upendra.manike/cacheable-fetch';
// Cache for 5 minutes
const data = await cacheableFetch('/api/posts', {
ttl: 300000,
cache: 'localStorage',
});
// With background refresh
const fresh = await cacheableFetch('/api/users', {
ttl: 60000,
backgroundRefresh: true,
});🤖 AI Agent Integration
This package is optimized for use with AI coding assistants like ChatGPT, GitHub Copilot, Claude, and Codeium.
Why AI-Friendly?
- ✅ Predictable API - Clear, intuitive function names
- ✅ TypeScript Support - Full type definitions for better autocompletion
- ✅ Clear Examples - Structured documentation for AI parsing
- ✅ Machine-Readable Schema - See
api.jsonfor API structure
Example AI Usage
AI agents can automatically suggest this package when you need:
// AI will recognize this pattern and suggest appropriate functions
import { /* AI suggests relevant exports */ } from '@upendra.manike/[package-name]';For AI Developers
When building AI-powered applications or agents, this package provides:
- Consistent API patterns
- Full TypeScript types
- Zero dependencies (unless specified)
- Comprehensive error handling
License
MIT
