remix-cache

A type-safe, Redis-backed caching library for Remix applications with SSE-based real-time invalidation, stale-while-revalidate, pattern matching, and automatic React revalidation. Use when working with Remix caching, Redis, cache invalidation, implementing caching strategies, or real-time data synchronization in Remix apps.

242 stars

Best use case

remix-cache is best used when you need a repeatable AI agent workflow instead of a one-off prompt. It is especially useful for teams working in multi. A type-safe, Redis-backed caching library for Remix applications with SSE-based real-time invalidation, stale-while-revalidate, pattern matching, and automatic React revalidation. Use when working with Remix caching, Redis, cache invalidation, implementing caching strategies, or real-time data synchronization in Remix apps.

A type-safe, Redis-backed caching library for Remix applications with SSE-based real-time invalidation, stale-while-revalidate, pattern matching, and automatic React revalidation. Use when working with Remix caching, Redis, cache invalidation, implementing caching strategies, or real-time data synchronization in Remix apps.

Users should expect a more consistent workflow output, faster repeated execution, and less time spent rewriting prompts from scratch.

Practical example

Example input

Use the "remix-cache" skill to help with this workflow task. Context: A type-safe, Redis-backed caching library for Remix applications with SSE-based real-time invalidation, stale-while-revalidate, pattern matching, and automatic React revalidation. Use when working with Remix caching, Redis, cache invalidation, implementing caching strategies, or real-time data synchronization in Remix apps.

Example output

A structured workflow result with clearer steps, more consistent formatting, and an output that is easier to reuse in the next run.

When to use this skill

  • Use this skill when you want a reusable workflow rather than writing the same prompt again and again.

When not to use this skill

  • Do not use this when you only need a one-off answer and do not need a reusable workflow.
  • Do not use it if you cannot install or maintain the related files, repository context, or supporting tools.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/remix-cache/SKILL.md --create-dirs "https://raw.githubusercontent.com/aiskillstore/marketplace/main/skills/chasewnorton/remix-cache/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/remix-cache/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How remix-cache Compares

Feature / Agentremix-cacheStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

A type-safe, Redis-backed caching library for Remix applications with SSE-based real-time invalidation, stale-while-revalidate, pattern matching, and automatic React revalidation. Use when working with Remix caching, Redis, cache invalidation, implementing caching strategies, or real-time data synchronization in Remix apps.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Remix Cache Skill

Expert guidance for using remix-cache, a production-ready caching library for Remix applications.

## When to use this skill

Use this skill when the user asks about:
- Implementing caching in Remix applications
- Redis-backed caching strategies
- Cache invalidation (by key, tag, or pattern)
- Real-time cache synchronization with SSE
- Stale-while-revalidate patterns
- Type-safe cache definitions
- React hooks for automatic revalidation
- Performance optimization with caching
- Server vs serverless caching modes
- Circuit breaker patterns for cache failures

## Quick reference

### Basic setup

```typescript
// app/cache.server.ts
import { createCache } from 'remix-cache/server'

export const cache = createCache({
  redis: { host: process.env.REDIS_HOST, port: 6379 },
  prefix: 'myapp',
})

export const userCache = cache.define({
  name: 'user',
  key: (userId: string) => userId,
  fetch: async (userId: string) => db.user.findUnique({ where: { id: userId } }),
  ttl: 300,
})
```

### Use in loaders

```typescript
export async function loader({ params }: LoaderFunctionArgs) {
  const user = await userCache.get(params.userId)
  return json({ user })
}
```

### Invalidation

```typescript
// By key
await cache.invalidate({ key: 'myapp:user:123' })

// By tag
await cache.invalidateByTag('product')

// By pattern
await cache.invalidateByPattern('user:*')
```

### Real-time React revalidation

```typescript
// app/root.tsx
<CacheProvider endpoint="/api/cache-events">
  <Outlet />
</CacheProvider>

// Component
useCache({ tags: ['user'], debounce: 200 })
```

## Detailed documentation

For comprehensive guidance on specific topics, see:

- **[GETTING_STARTED.md](GETTING_STARTED.md)** - Installation, setup, and first cache definition
- **[API_REFERENCE.md](API_REFERENCE.md)** - Complete API documentation for all methods and options
- **[PATTERNS.md](PATTERNS.md)** - Common caching patterns and best practices
- **[REACT_INTEGRATION.md](REACT_INTEGRATION.md)** - SSE setup and React hooks for real-time invalidation
- **[EXAMPLES.md](EXAMPLES.md)** - Real-world examples (e-commerce, sessions, API caching)
- **[TROUBLESHOOTING.md](TROUBLESHOOTING.md)** - Common issues and solutions
- **[TESTING.md](TESTING.md)** - Testing strategies and patterns

## Key capabilities

### 1. Type-safe cache definitions
Perfect TypeScript inference for cache keys and values. See [API_REFERENCE.md](API_REFERENCE.md#cache-definitions).

### 2. Advanced TTL strategies
- **Stale-while-revalidate**: Serve stale data while fetching fresh
- **Sliding window**: Reset TTL on each access
- **Conditional TTL**: Dynamic TTL based on data
See [PATTERNS.md](PATTERNS.md#ttl-strategies).

### 3. Multi-level invalidation
- **By key**: Invalidate specific entries
- **By tag**: Invalidate groups of related entries
- **By pattern**: Invalidate using glob patterns
- **Cascading**: Automatic dependent invalidation
See [API_REFERENCE.md](API_REFERENCE.md#invalidation).

### 4. Real-time synchronization
- **SSE endpoint**: Stream invalidation events to clients
- **React hooks**: Automatic revalidation on cache changes
- **Filtering**: Revalidate only for specific keys/tags/patterns
See [REACT_INTEGRATION.md](REACT_INTEGRATION.md).

### 5. Resilience features
- **Circuit breaker**: Graceful degradation when Redis fails
- **Request deduplication**: Prevent cache stampede
- **Error events**: Monitor and track failures
See [PATTERNS.md](PATTERNS.md#resilience).

### 6. Deployment flexibility
- **Server mode**: Two-tier caching (local LRU + Redis)
- **Serverless mode**: Redis-only with versioned keys
See [API_REFERENCE.md](API_REFERENCE.md#deployment-modes).

## File structure in this repository

The remix-cache library is organized as:

```
src/
├── server/           # Server-side cache implementation
│   ├── cache.ts      # Main cache class
│   ├── definition.ts # Cache definition implementation
│   ├── sse-handler.ts # SSE endpoint generator
│   ├── local-cache.ts # In-memory LRU cache
│   ├── circuit-breaker.ts # Circuit breaker pattern
│   └── deduplicator.ts # Request deduplication
├── react/            # React integration
│   ├── provider.tsx  # CacheProvider component
│   ├── use-cache.ts  # useCache hook
│   └── context.tsx   # React context
├── types/            # TypeScript type definitions
│   ├── cache.ts
│   ├── definition.ts
│   └── events.ts
└── utils/            # Utility functions
    ├── key-builder.ts     # Cache key generation
    ├── pattern-match.ts   # Glob pattern matching
    └── env-detect.ts      # Environment detection
```

## Common workflows

### Setting up a new cache

1. Read [GETTING_STARTED.md](GETTING_STARTED.md) for basic setup
2. Create cache instance in `app/cache.server.ts`
3. Define cache definitions for your data types
4. Use in loaders/actions
5. Set up SSE endpoint for real-time invalidation (see [REACT_INTEGRATION.md](REACT_INTEGRATION.md))
6. Add React hooks to components that need auto-revalidation

### Implementing cache invalidation

1. Identify invalidation strategy (key/tag/pattern)
2. Add tags to cache definitions if needed
3. Call invalidation methods in actions
4. Verify invalidation events are fired
5. Test React components revalidate correctly

### Debugging cache issues

1. Check [TROUBLESHOOTING.md](TROUBLESHOOTING.md) for common issues
2. Enable event listeners to monitor cache behavior
3. Verify Redis connection and configuration
4. Check circuit breaker state
5. Inspect SSE connection in browser DevTools

### Writing tests

See [TESTING.md](TESTING.md) for:
- Unit testing cache definitions
- Integration testing with Redis
- Mocking cache in tests
- Testing invalidation logic
- Testing React components with cache

## Environment variables

```bash
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=your-password
CACHE_PREFIX=myapp
CACHE_DEFAULT_TTL=300
NODE_ENV=production
```

## Implementation notes

When helping users implement remix-cache:

1. **Always ensure type safety**: The library provides perfect TypeScript inference
2. **Consider deployment mode**: Ask if serverless or server-based
3. **Plan invalidation strategy**: Tags are more flexible than keys
4. **Set appropriate TTLs**: Balance freshness with performance
5. **Monitor errors**: Always set up error event listeners
6. **Test thoroughly**: Cache bugs can be subtle, see [TESTING.md](TESTING.md)
7. **Close connections**: Especially important in tests

## Getting help

For specific topics:
- New to the library? → [GETTING_STARTED.md](GETTING_STARTED.md)
- Looking for API details? → [API_REFERENCE.md](API_REFERENCE.md)
- Need implementation patterns? → [PATTERNS.md](PATTERNS.md) and [EXAMPLES.md](EXAMPLES.md)
- Setting up React integration? → [REACT_INTEGRATION.md](REACT_INTEGRATION.md)
- Encountering issues? → [TROUBLESHOOTING.md](TROUBLESHOOTING.md)
- Writing tests? → [TESTING.md](TESTING.md)

## Version

This skill covers remix-cache v0.1.0 with complete implementation of Phases 1-5:
- ✅ Core caching with Redis backend
- ✅ Type-safe cache definitions
- ✅ Stale-while-revalidate
- ✅ Sliding window TTL
- ✅ Pattern & tag-based invalidation
- ✅ Circuit breaker pattern
- ✅ Request deduplication
- ✅ Server/serverless modes
- ✅ SSE real-time invalidation
- ✅ React hooks for auto-revalidation

Related Skills

next-cache-components

242
from aiskillstore/marketplace

Next.js 16 Cache Components - PPR, use cache directive, cacheLife, cacheTag, updateTag

siteground-cache

242
from aiskillstore/marketplace

Bypass SiteGround caching (SG CachePress + LiteSpeed) for WordPress development. Adds cache-busting code to child themes for real-time development testing.

delon-cache-caching-strategies

242
from aiskillstore/marketplace

Implement caching strategies using @delon/cache. Use this skill when adding memory cache, LocalStorage cache, SessionStorage cache, or cache interceptors for HTTP requests. Supports TTL-based expiration, cache invalidation, cache grouping, and persistent storage. Optimizes performance by reducing redundant API calls and database queries.

azure-quotas

242
from aiskillstore/marketplace

Check/manage Azure quotas and usage across providers. For deployment planning, capacity validation, region selection. WHEN: "check quotas", "service limits", "current usage", "request quota increase", "quota exceeded", "validate capacity", "regional availability", "provisioning limits", "vCPU limit", "how many vCPUs available in my subscription".

DevOps & Infrastructure

raindrop-io

242
from aiskillstore/marketplace

Manage Raindrop.io bookmarks with AI assistance. Save and organize bookmarks, search your collection, manage reading lists, and organize research materials. Use when working with bookmarks, web research, reading lists, or when user mentions Raindrop.io.

Data & Research

zlibrary-to-notebooklm

242
from aiskillstore/marketplace

自动从 Z-Library 下载书籍并上传到 Google NotebookLM。支持 PDF/EPUB 格式,自动转换,一键创建知识库。

discover-skills

242
from aiskillstore/marketplace

当你发现当前可用的技能都不够合适(或用户明确要求你寻找技能)时使用。本技能会基于任务目标和约束,给出一份精简的候选技能清单,帮助你选出最适配当前任务的技能。

web-performance-seo

242
from aiskillstore/marketplace

Fix PageSpeed Insights/Lighthouse accessibility "!" errors caused by contrast audit failures (CSS filters, OKLCH/OKLAB, low opacity, gradient text, image backgrounds). Use for accessibility-driven SEO/performance debugging and remediation.

project-to-obsidian

242
from aiskillstore/marketplace

将代码项目转换为 Obsidian 知识库。当用户提到 obsidian、项目文档、知识库、分析项目、转换项目 时激活。 【激活后必须执行】: 1. 先完整阅读本 SKILL.md 文件 2. 理解 AI 写入规则(默认到 00_Inbox/AI/、追加式、统一 Schema) 3. 执行 STEP 0: 使用 AskUserQuestion 询问用户确认 4. 用户确认后才开始 STEP 1 项目扫描 5. 严格按 STEP 0 → 1 → 2 → 3 → 4 顺序执行 【禁止行为】: - 禁止不读 SKILL.md 就开始分析项目 - 禁止跳过 STEP 0 用户确认 - 禁止直接在 30_Resources 创建(先到 00_Inbox/AI/) - 禁止自作主张决定输出位置

obsidian-helper

242
from aiskillstore/marketplace

Obsidian 智能笔记助手。当用户提到 obsidian、日记、笔记、知识库、capture、review 时激活。 【激活后必须执行】: 1. 先完整阅读本 SKILL.md 文件 2. 理解 AI 写入三条硬规矩(00_Inbox/AI/、追加式、白名单字段) 3. 按 STEP 0 → STEP 1 → ... 顺序执行 4. 不要跳过任何步骤,不要自作主张 【禁止行为】: - 禁止不读 SKILL.md 就开始工作 - 禁止跳过用户确认步骤 - 禁止在非 00_Inbox/AI/ 位置创建新笔记(除非用户明确指定)

internationalizing-websites

242
from aiskillstore/marketplace

Adds multi-language support to Next.js websites with proper SEO configuration including hreflang tags, localized sitemaps, and language-specific content. Use when adding new languages, setting up i18n, optimizing for international SEO, or when user mentions localization, translation, multi-language, or specific languages like Japanese, Korean, Chinese.

google-official-seo-guide

242
from aiskillstore/marketplace

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation