Cache strategist
Skill AtulPurohit/Antigravity-Awesome-Skills/skills/cache-strategist
Installable GitHub library of 300+ professional agentic skills for Claude Code, Antigravity IDE, Gemini CLI, Cursor, and Copilot. Features a custom NPX installer, 9 stack-specific bundles, validation schemas, security auditing, and an interactive catalog explorer app.
npx -y skills add AtulPurohit/Antigravity-Awesome-Skills --skill cache-strategistAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
3 things to look at
- 26 days oldThe repository was created 26 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Design comprehensive caching strategies across all layers: browser cache, CDN, application cache, database query cache, and Redis. Maximize performance while maintaining data freshness.
SKILL.md
5.2 KB, as published. Nobody here has run it
Cache Strategist
Purpose
Design and implement a multi-layer caching strategy that dramatically improves application performance while ensuring appropriate data freshness.
Operating Mode
You are a performance and caching engineer. You identify what to cache, for how long, and design invalidation strategies that prevent stale data.
Caching Layers
1️⃣ Cache Layer Architecture
Client Browser Cache
↓
CDN Cache (Cloudflare, CloudFront)
↓
Application Cache (Redis, Memcached)
↓
Database Query Cache
↓
Database (MySQL, PostgreSQL)
2️⃣ What to Cache (Decision Matrix)
| Data Type | Cache? | TTL | Reason |
|---|---|---|---|
| Static assets (JS/CSS/images) | ✅ Yes | 1 year + CDN | Never changes (content hash) |
| Public page HTML | ✅ Yes | 5-60 min | High traffic, slow to generate |
| User session | ✅ Yes | 2 hours | Every request needs it |
| Auth tokens | ✅ Yes | Token lifetime | Speed, avoid DB per request |
| Search results | ✅ Yes | 5 min | Expensive queries |
| Product catalog | ✅ Yes | 1 hour | Changes infrequently |
| User-specific data | ⚠️ Selective | 30 min | Risk of stale user data |
| Financial totals | ❌ No | 0 | Must be accurate |
| Real-time stock | ❌ No | 0 | Always fresh |
3️⃣ Cache Patterns
Cache-Aside (Lazy Loading)
function getUser(int $id): User
{
$key = "user:{$id}";
if ($cached = Cache::get($key)) {
return $cached; // Cache hit
}
$user = User::find($id); // Cache miss - hit DB
Cache::put($key, $user, ttl: 3600);
return $user;
}
Write-Through
function updateUser(int $id, array $data): User
{
$user = User::findOrFail($id)->update($data);
Cache::put("user:{$id}", $user, 3600); // Always update cache
return $user;
}
Read-Through (pattern with Repository)
class CachedUserRepository
{
public function find(int $id): ?User
{
return Cache::remember("user:{$id}", 3600, fn() =>
$this->db->find($id) // Only fetches when cache misses
);
}
}
Cache-Aside with Stampede Prevention
function getExpensiveData(string $key): mixed
{
// Use atomic lock to prevent stampede
return Cache::lock("lock:{$key}", seconds: 10)
->block(seconds: 5, callback: fn() =>
Cache::remember($key, 300, fn() => computeExpensiveData())
);
}
4️⃣ Cache Invalidation Strategies
Tag-Based Invalidation
// Store with tags
Cache::tags(['posts', "user:123"])->put("post:456", $post, 3600);
// Invalidate user's cached posts when user updates
public function updateUser(User $user, array $data): void
{
$user->update($data);
Cache::tags(["user:{$user->id}"])->flush(); // Clears all user's cached data
}
Event-Driven Invalidation
// Listen to model events
class Post extends Model
{
protected static function booted(): void
{
static::saved(fn($post) => Cache::forget("post:{$post->id}"));
static::deleted(fn($post) => Cache::forget("post:{$post->id}"));
}
}
5️⃣ CDN Configuration (Cloudflare)
# Page rules for caching:
# Cache static assets for 1 year
*.js, *.css, *.png, *.woff2
Cache-Control: public, max-age=31536000, immutable
# Cache API responses for 60 seconds
/api/v1/products*
Cache-Control: public, s-maxage=60, stale-while-revalidate=300
# Never cache
/api/v1/cart, /api/v1/auth/*
Cache-Control: no-store
# Vary header for content negotiation
Vary: Accept-Encoding, Accept
6️⃣ Redis Cache Configuration
// config/cache.php
'redis' => [
'driver' => 'redis',
'connection' => 'cache', // Separate Redis DB for cache
'lock_connection' => 'default',
],
// Separate Redis connection for cache vs sessions vs queues
'connections' => [
'default' => ['url' => env('REDIS_URL'), 'database' => 0], // Default/sessions
'cache' => ['url' => env('REDIS_CACHE_URL'), 'database' => 1], // Cache
'queue' => ['url' => env('REDIS_QUEUE_URL'), 'database' => 2], // Queues
],
7️⃣ Monitoring Cache Performance
# Redis cache hit rate monitoring
redis-cli info stats | grep keyspace_hits
redis-cli info stats | grep keyspace_misses
# Target: > 95% hit rate for frequently accessed data
# Formula: hits / (hits + misses) * 100
# Monitor memory usage
redis-cli info memory | grep used_memory_human
# List largest keys (find memory hogs)
redis-cli --bigkeys
Outputs
- Multi-layer caching strategy document
- Cache implementation code (per framework)
- Invalidation strategy for each entity type
- CDN configuration
- Cache monitoring dashboard queries
- Performance baseline and targets