thibautbaissac/rails_ai_agents/caching-patterns
Claude Code and agent skill by thibautbaissac/rails_ai_agents
- community
Checking that the SKILL.md file is still in the repository.
Implements HTTP caching with ETags, fragment caching, Russian doll caching, and Solid Cache configuration. Use when optimizing performance, adding caching layers, or when user mentions ETags, fresh_when, stale?, cache keys, or Russian doll caching. WHEN NOT: For Turbo Stream real-time updates (use turbo-patterns), for background job cache warming logic (use job-patterns).
Install
npx vskill@latest install thibautbaissac/rails_ai_agents/caching-patternsSKILL.md
Caching Patterns
Philosophy: Cache Aggressively, Invalidate Precisely
- HTTP caching with ETags and
fresh_whenfor free 304 Not Modified responses - Russian doll caching with
touch: truefor automatic cache invalidation - Fragment caching in views with cache keys based on
updated_attimestamps - Solid Cache (database-backed, no Redis) for production caching
- Collection caching with
cache_collectionfor lists - Low-level caching with
Rails.cache.fetchfor expensive computations
Project Knowledge
Stack: Solid Cache (database-backed), Turbo for page refreshes, ETags with conditional GET, fragment caching in ERB views, collection caching for lists.
Multi-tenancy: Cache keys scoped to account. URL-based: app.myapp.com/123/projects/456.
Commands:
Caching Strategy Hierarchy
Apply caching in this order (highest impact first):
- HTTP caching --
fresh_when/stale?in controllers (free 304s) - Fragment caching --
cacheblocks in views (Russian doll) - Collection caching --
cache_collectionfor lists of partials - Low-level caching --
Rails.cache.fetchfor expensive computations
Pattern 1: HTTP Caching with ETags
See @references/http-caching.md for full details.
Pattern 2: Russian Doll Caching
See @references/fragment-caching.md for full details.
Set up touch cascades in models:
Nest cache blocks in views:
Pattern 3: Collection Caching
Use counter caches to avoid N+1 in cache keys:
Pattern 4: Fragment Caching with Custom Keys
Pattern 5: Low-Level Caching
Pattern 6: Cache Invalidation
See @references/cache-invalidation.md for full details.
Pattern 7: Solid Cache Configuration
Pattern 8: Cache Warming
Boundaries
Always
- Use
fresh_whenfor index and show actions - Use
touch: trueon associations for automatic invalidation - Use Solid Cache in production (database-backed, no Redis)
- Include
expires_infor time-based data - Scope cache keys to account in multi-tenant apps
- Use counter caches for counts
- Eager load associations to prevent N+1 queries
Ask First
- Whether to cache user-specific content
- Cache expiration times (freshness vs performance)
- Whether to warm caches in background jobs
Never
- Use Redis for caching (use Solid Cache)
- Cache without considering invalidation strategy
- Forget
touch: truewith Russian doll caching - Cache CSRF tokens or sensitive user data
- Use generic cache keys without version/timestamp
- Cache in test environment (use
:null_store) - Cache across account boundaries in multi-tenant apps
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.claude_37signals/skills/caching-patterns/SKILL.md
Popularity
- Repository stars
- 589
- Repository forks
- 67
- 7-day trend score
- 32
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/thibautbaissac/rails_ai_agents/caching-patterns)