Λογότυπο Caching Strategy

Caching Strategy

Οργανισμός
SkillMedev
caching-strategy

Designs multi-layer caching - CDN, application, and database - choosing the pattern, TTL, and invalidation plan per data type, and produces a cache-decision table plus stampede protection. Use when someone asks "should I cache this", "Redis or CDN for this endpoint", "how do I invalidate this cache", "why is my cache hit rate so low", or is bolting Redis onto a slow service. Do NOT use for sizing or tuning database connection pools - use connection-pool-tuner instead - and do NOT use for frontend bundle, image, or Core Web Vitals work - use web-performance instead.

Επισκόπηση

ΕκδότηςSkillMedev
Αποθετήριοskills
Όνομα δεξιότηταςcaching-strategy
Αστέρια
25
Forks
3
Συνοδευτικά αρχεία
Μόνο οδηγίες
Άδεια χρήσηςMIT
Σύνδεσμοι
  • Οδηγίες σε Markdown

    Ένα αρχείο SKILL.md που το μοντέλο φορτώνει όταν χρειάζεται, ώστε να καταναλώνει token μόνο όταν ένα αίτημα είναι πράγματι σχετικό.

  • Λειτουργεί με οποιοδήποτε LLM

    Οι δεξιότητες AI είναι απλό Markdown, όχι κώδικας για συγκεκριμένο πάροχο, επομένως αυτή η δεξιότητα λειτουργεί με GPT, Claude, Gemini, Grok ή ένα τοπικό μοντέλο.

  • Αυτοτελής

    Όλα όσα χρειάζεται το μοντέλο περιλαμβάνονται στις οδηγίες — χωρίς επιπλέον αρχεία για συγχρονισμό.

  • Ανοιχτού κώδικα

    Δημοσιεύτηκε από SkillMedev στο GitHub. Διαβάστε το πηγαίο περιεχόμενο πριν εγκαταστήσετε τη δεξιότητα.

Εγκατάσταση

Εγκαταστήστε τη δεξιότητα AI Caching Strategy στο TypingMind για να τη χρησιμοποιείτε με οποιοδήποτε LLM ή προσθέστε τη σε άλλον πράκτορα AI που διαβάζει αρχεία SKILL.md.

1

Εγκατάσταση στο TypingMind

Το TypingMind εγκαθιστά μια δεξιότητα απευθείας από τον φάκελό της στο GitHub — διαβάζει το SKILL.md, συγκεντρώνει τα συνοδευτικά αρχεία σε πακέτο και αποθηκεύει το αποτέλεσμα τοπικά.

  1. Ανοίξτε την εφαρμογή και μεταβείτε στα Πρόσθετα → Δεξιότητες.
  2. Επιλέξτε «Εγκατάσταση από GitHub».
  3. Επικολλήστε το παρακάτω URL του φακέλου της δεξιότητας και επιβεβαιώστε.
    https://github.com/SkillMedev/skills/tree/main/skills/caching-strategy
  4. Ενεργοποιήστε τη δεξιότητα σε κάθε συνομιλία όπου θέλετε να είναι διαθέσιμη.
Πρόσθετα → Δεξιότητες → Νέα δεξιότητα → Από URL του GitHub, έπειτα επικολλήστε το URL του φακέλου και πατήστε «Συνέχεια».
2

Εγκατάσταση σε άλλον πράκτορα AI

Κάθε πράκτορας AI που διαβάζει τη μορφή Agent Skills μπορεί να χρησιμοποιήσει αυτή τη δεξιότητα — αντιγράψτε τον φάκελο στον κατάλογο δεξιοτήτων του.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/SkillMedev/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/skills/caching-strategy .claude/skills/caching-strategy
Επανεκκινήστε το Claude Code μετά την αντιγραφή, ώστε να εντοπίσει τη νέα δεξιότητα.

Χρησιμοποιήστε τη στο TypingMind

Ενεργοποιήστε τη δεξιότητα Caching Strategy σε οποιαδήποτε συνομιλία στο TypingMind και το μοντέλο αναλαμβάνει τα υπόλοιπα. Το όνομα και η περιγραφή της περιλαμβάνονται στην προτροπή συστήματος και, μόλις προκύψει ένα σχετικό αίτημα, το μοντέλο φορτώνει μόνο του τις πλήρεις οδηγίες — δεν χρειάζεται ποτέ να την καλείτε χειροκίνητα και δεν καταναλώνει token μέχρι να χρησιμοποιηθεί πραγματικά.

Το μοντέλο φορτώνει αυτόματα τη δεξιότητα Caching Strategy μόλις λάβει ένα σχετικό αίτημα.

Λειτουργεί με οποιοδήποτε μοντέλο AI

Οι δεξιότητες AI είναι απλές οδηγίες Markdown και όχι κώδικας για συγκεκριμένο πάροχο, οπότε η δεξιότητα Caching Strategy δεν περιορίζεται στο μοντέλο για το οποίο γράφτηκε. Εγκαταστήστε τη μία φορά στο TypingMind και χρησιμοποιήστε τη με GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ή ένα τοπικό μοντέλο που εκτελείτε εσείς — πάντα με τα δικά σας κλειδιά API.

  • Φόρτωση μόνο όταν χρειάζεται

    Η προτροπή συστήματος περιλαμβάνει μόνο το όνομα και την περιγραφή. Οι οδηγίες ανακτώνται με το πρώτο σχετικό αίτημα, οπότε μια δεξιότητα που δεν χρησιμοποιείται δεν έχει κόστος.

  • Αλλάξτε μοντέλα κατά τη συνομιλία

    Επειδή η δεξιότητα αποτελείται από οδηγίες και όχι από κώδικα, η αλλαγή μοντέλου δεν επηρεάζει τη λειτουργία της — το επόμενο μοντέλο διαβάζει το ίδιο αρχείο SKILL.md.

Οδηγίες δεξιότητας

Αυτό είναι το περιεχόμενο του αρχείου SKILL.md που φορτώνει το μοντέλο. Διαβάστε το πριν από την εγκατάσταση — μια δεξιότητα αποτελείται από οδηγίες που θα ακολουθήσει το μοντέλο σας.

Caching Strategy

A cache is a correctness liability you accept in exchange for latency, so every cache needs an explicit answer to "how stale can this be?" and "how does it get invalidated?" before it ships. The costly mistake this skill prevents is the write-only cache: a layer that adds a network hop and an invalidation bug surface while its hit rate quietly sits below 50 percent, making the system slower and wronger at the same time.

Operating procedure

Work per data type, not per system - "cache the API" is not a decision, "cache the product listing for 60s at the CDN" is.

Step 1: Gather inputs

Collect these for each candidate data type. If a number is an estimate, label it a guess and refine from production metrics later.

  1. Read:write ratio. How many reads per write to the same key.
  2. Recompute cost. Latency of a cache miss (DB query, computation, upstream call).
  3. Staleness tolerance. How stale a value can be before it causes a user-visible or business-logic error. Get a number in seconds, not "pretty fresh".
  4. Key cardinality and object size. Millions of small keys behave differently from thousands of megabyte blobs.
  5. Whether the data is user-specific or shared.

Step 2: Decide whether to cache at all

  • Read:write below 3:1 or recompute cost under 5ms: do not cache. The invalidation complexity buys almost nothing.
  • Read:write at 10:1 or higher, or recompute cost over 20ms: strong candidate.
  • In between: cache only if you can use plain TTL invalidation (Step 5). Event-based invalidation is not worth it for marginal wins.

Step 3: Pick the layer

Cache as close to the consumer as correctness allows.

  1. Browser/CDN for static assets and shared, cacheable responses. Hashed static assets get Cache-Control: public, max-age=31536000, immutable; dynamic-but-shared responses get short max-age plus stale-while-revalidate; conditional revalidation uses ETag/If-None-Match.
  2. Application layer (in-memory or Redis) for computed results, hot objects, and session-adjacent data.
  3. Database layer (materialized views, read replicas) when the expensive part is the query itself and many app nodes need the same answer.

Never cache user-specific data at a shared/public layer - that is an auth-leak class of bug, not a performance bug.

Step 4: Pick the pattern

  • Cache-aside (lazy) is the default: on miss, load from source, store with TTL, return. Choose anything else only with a stated reason.
  • Read-through/write-through when you want the cache library to own consistency and you accept write latency.
  • Write-behind only for loss-tolerant data (metrics, counters) - buffered writes can vanish on crash.

Step 5: Set TTL and invalidation from staleness tolerance

  • Staleness tolerance ≥ 5 minutes: TTL-only. Set TTL to roughly half the tolerance and stop - this is the cheapest correct design.
  • Tolerance between ~10 seconds and 5 minutes: short TTL plus best-effort delete-on-write for the hot paths.
  • Tolerance under ~10 seconds ("must be fresh"): event-based invalidation (delete or update the key inside the write path), with a short TTL (60-300s) as the escape hatch. Never cache without an expiry escape hatch.
  • Invalidate whole sets with version keys (user:123:v2 - bump the version, old keys age out) rather than trying to enumerate and delete members.

Step 6: Protect against stampedes and penetration

When a hot key expires, every concurrent request rebuilds it at once.

  • Add ±10-20% random jitter to TTLs so keys don't expire simultaneously.
  • Single-flight lock: one request recomputes, others wait or serve stale.
  • Serve-stale-while-revalidate: return the old value, refresh in the background.
  • Cache penetration (repeated queries for keys that don't exist): cache the negative result for 30-60s.
  • Redis hot-key or big-key: replicate the hot value across shards or split the big value; a single 10MB key on one shard becomes the whole cluster's bottleneck.

Step 7: Instrument and set the kill threshold

Emit hit rate, miss latency, and eviction rate per cache from day one. Expectations: 90%+ for CDN static assets, 80%+ for application-layer caches of hot objects, 60%+ minimum for anything else. A cache holding under 50% hit rate after tuning TTL and key design should be removed - it is adding a hop and a failure mode for nothing. Choose an eviction policy deliberately: LRU is the default; LFU when a stable hot set is scanned by long-tail traffic.

Worked artifact: cache-decision table

Produce one row per data type. Filled example for an e-commerce API:

DataRead:writeRecomputeStaleness tol.LayerPatternTTLInvalidationTarget hit rate
Product detail500:145ms5 minCDN + Rediscache-aside120s ±15% jitterTTL only85%
Cart contents4:18ms0snone----
Price by SKU200:130ms5sRediscache-aside60s escape hatchdelete-on-write80%
Search results50:1300ms10 minRedisstale-while-revalidate300s ±20%TTL only70%
User session20:112ms0sRedis (keyed per user)write-through24h idledelete on logout95%

Note the cart row: high write rate and zero staleness tolerance means the correct decision is no cache.

Copy-paste skeleton:

CACHE DECISION TABLE - [FILL: service name]
| Data | Read:write | Recompute cost | Staleness tolerance | Layer | Pattern | TTL + jitter | Invalidation | Target hit rate |
| [FILL] | [FILL] | [FILL]ms | [FILL]s | [FILL] | [FILL] | [FILL] | [FILL] | [FILL]% |
Stampede protection: [FILL: jitter / single-flight / stale-while-revalidate]
Kill threshold: remove any row that holds < 50% hit rate after tuning.

Deliverable

Produce a cache-decision table (one row per data type with layer, pattern, TTL, invalidation, and target hit rate), the stampede-protection choice for each hot key, and the monitoring plan naming the hit-rate threshold at which each cache gets removed.

Do NOT

  • Do not cache without a TTL escape hatch - event-based invalidation always has a missed-event path, and a key with no expiry serves wrong data forever.
  • Do not cache user-specific data in a shared cache; that is how one user sees another's account.
  • Do not add event-based invalidation to data that tolerates minutes of staleness - TTL-only is simpler and equally correct.
  • Do not judge success by "the endpoint got faster" alone; a 40% hit rate cache made the p50 faster and the p99 worse.
  • Do not let all keys share an exact TTL - synchronized expiry is a self-inflicted stampede.
  • Do not accept eventual consistency silently across nodes; either state it in the design or add pub/sub invalidation.

Quality bar

  • Every cached data type has a numeric staleness tolerance and a TTL derived from it.
  • Every cache has a named invalidation mechanism and an expiry escape hatch.
  • Hot keys have explicit stampede protection (jitter at minimum).
  • Hit rate, miss latency, and evictions are instrumented, with the sub-50% removal rule written down.
  • The table contains at least one deliberate "do not cache" row - a design that caches everything was not analyzed.

Escalation

If the miss path is slow because of a bad query plan, fix the query before caching over it - route to sql-query-optimizer or index-advisor. If latency comes from connection acquisition rather than compute, use connection-pool-tuner. For browser-side performance beyond HTTP cache headers, use web-performance.

Συχνές ερωτήσεις

Τι κάνει η δεξιότητα AI Caching Strategy;

Designs multi-layer caching - CDN, application, and database - choosing the pattern, TTL, and invalidation plan per data type, and produces a cache-decision table plus stampede protection. Use when someone asks "should I cache this", "Redis or CDN for this endpoint", "how do I invalidate this cache", "why is my cache hit rate so low", or is bolting Redis onto a slow service. Do NOT use for sizing or tuning database connection pools - use connection-pool-tuner instead - and do NOT use for frontend bundle, image, or Core Web Vitals work - use web-performance instead.

Γιατί να χρησιμοποιήσετε τη δεξιότητα Caching Strategy στο TypingMind;

Επειδή την εγκαθιστάτε μία φορά και τη χρησιμοποιείτε με οποιοδήποτε μοντέλο. Η Caching Strategy είναι απλό Markdown και όχι κώδικας ειδικά για κάποιον πάροχο, επομένως η ίδια δεξιότητα λειτουργεί με GPT-5, Claude, Gemini, Grok ή ένα τοπικό μοντέλο — και μπορείτε να αλλάξετε μοντέλο κατά τη διάρκεια της συνομιλίας χωρίς να διακοπεί η λειτουργία της. Το TypingMind λειτουργεί με τα δικά σας κλειδιά API, οπότε πληρώνετε απευθείας τους παρόχους αντί για συνδρομή ανά θέση χρήστη, ενώ οι δεξιότητες και οι συνομιλίες σας παραμένουν στον δικό σας χώρο αποθήκευσης.

Πώς εγκαθιστώ τη Caching Strategy στο TypingMind;

Στο TypingMind, ανοίξτε Πρόσθετα → Δεξιότητες → Εγκατάσταση από το GitHub και επικολλήστε το https://github.com/SkillMedev/skills/tree/main/skills/caching-strategy. Το TypingMind διαβάζει το αρχείο SKILL.md και εγκαθιστά τη δεξιότητα, την οποία μπορείτε να ενεργοποιείτε ανά συνομιλία.

Ποια μοντέλα AI μπορούν να χρησιμοποιήσουν τη δεξιότητα Caching Strategy;

Οποιοδήποτε μοντέλο συνδέετε στο TypingMind. Οι δεξιότητες AI είναι απλές οδηγίες Markdown και όχι κώδικας ειδικά για κάποιον πάροχο, επομένως τα GPT, Claude, Gemini, Grok και τα τοπικά μοντέλα μπορούν όλα να φορτώσουν αυτή τη δεξιότητα όταν ένα αίτημα αντιστοιχεί σε αυτή.

Με πόσα μοντέλα AI μπορώ να χρησιμοποιήσω τη Caching Strategy;

Με όσα θέλετε. Εφόσον ένα μοντέλο υποστηρίζει δεξιότητες, μπορείτε να χρησιμοποιήσετε τη Caching Strategy με αυτό — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama και άλλα — όλα στο TypingMind με τα δικά σας κλειδιά API.

Είναι δωρεάν η δεξιότητα AI Caching Strategy;

Ναι. Δημοσιεύεται στο GitHub από τον χρήστη SkillMedev με την άδεια χρήσης MIT. Πληρώνετε μόνο τον δικό σας πάροχο AI για τα token που χρησιμοποιείτε.

Τι είναι οι δεξιότητες AI;

Μια δεξιότητα AI είναι ένα επαναχρησιμοποιήσιμο πακέτο οδηγιών που διδάσκει σε ένα μοντέλο AI πώς να εκτελεί μια συγκεκριμένη εργασία. Ακολουθεί την ανοιχτή μορφή Agent Skills: ένα αρχείο SKILL.md με όνομα και περιγραφή, μαζί με τυχόν σενάρια κώδικα, πρότυπα ή αρχεία αναφοράς που μπορεί να χρειαστεί το μοντέλο. Το μοντέλο διαβάζει τις οδηγίες μόνο όταν το αίτημά σας αντιστοιχεί στη δεξιότητα, οπότε μια εγκατεστημένη δεξιότητα δεν κοστίζει τίποτα μέχρι να χρησιμοποιηθεί.

Σε τι διαφέρουν οι δεξιότητες AI από τα πρόσθετα ή τους συνδέσμους MCP;

Ένα πρόσθετο ή ένας σύνδεσμος MCP παρέχει στο μοντέλο νέα εργαλεία που μπορεί να καλέσει — κώδικα που εκτελείται κάπου και επιστρέφει ένα αποτέλεσμα. Μια δεξιότητα AI παρέχει αντί γι’ αυτό γνώσεις και διαδικασίες στο μοντέλο: πώς να προσεγγίσει μια εργασία, ποια βήματα να ακολουθήσει και ποια χαρακτηριστικά έχει ένα καλό αποτέλεσμα. Οι δεξιότητες είναι απλό Markdown, επομένως δεν χρειάζονται διακομιστή, κλειδί API ή περιβάλλον εκτέλεσης και λειτουργούν με οποιοδήποτε μοντέλο.

Προβολή όλων

Στήστε δικό σας χώρο εργασίας AI τώρα

Εγγραφείτε στο ενημερωτικό μας δελτίο για να ενημερώνεστε για νέες λειτουργίες και μελλοντικές κληρώσεις δώρων 👇