content-hash-cache-pattern

Cache file processing results using SHA-256 content hashes.

Updated May 4, 2026
One-click install
npx skills add https://github.com/gganbukim1/myskills --skill content-hash-cache-pattern-gganbukim1
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: content-hash-cache-pattern
Source: https://github.com/gganbukim1/myskills/tree/main/content-hash-cache-pattern
Command: npx skills add https://github.com/gganbukim1/myskills --skill content-hash-cache-pattern-gganbukim1

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves the problem of repeatedly performing expensive file processing (like PDF parsing, text extraction, and image analysis) even when the underlying file content has not changed.

Core Features & Use Cases

  • Content-hash cache keys: Use SHA-256 over file bytes so cache hits survive file renames/moves and invalidate automatically on content changes.
  • Simple file-per-entry storage: Store each cached result as {hash}.json for O(1) lookup without maintaining an index.
  • Service-layer separation: Keep extraction logic pure and wrap it with a cache-checking service layer to enable or disable caching via configuration.
  • Robustness for cache failures: Treat corrupted cache entries as misses so processing can self-heal on the next run.
  • Chunked hashing for large files: Hash in fixed-size chunks (e.g., 64KB) to avoid loading entire files into memory.

Quick Start

Ask the skill to implement a cache-enabled wrapper that computes a SHA-256 content hash for an input file and returns the cached extraction result when {hash}.json exists, otherwise extracts and writes the new cache entry.

Frequently Asked Questions about content-hash-cache-pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I avoid reprocessing PDF parsing results when files are moved or renamed?

Use SHA-256 content hashing to generate cache keys from file bytes. This ensures cache hits survive file renames or moves while invalidating automatically when underlying content actually changes.

What is the best way to cache expensive file processing results like OCR and text extraction?

The best way to cache file processing results is storing each extraction output as a separate {hash}.json file. This provides O(1) lookup speed without maintaining a separate index database for cached entries.

How does content-hash caching handle corrupted cache entries?

Content-hash caching treats corrupted cache entries as cache misses. This allows the extraction pipeline to self-heal by automatically reprocessing the file on the next run instead of failing permanently.

Can I hash large files for caching without loading entire content into memory?

Yes, you can hash large files in fixed-size chunks, such as 64KB blocks. Chunked hashing processes file streams incrementally to compute SHA-256 hashes without loading entire files into memory.

How do I structure my extraction logic to support toggling cache on and off?

Keep your extraction logic pure and wrap it with a service-layer cache-checking component. This separation enables you to turn caching on or off via configuration without modifying the core extraction function.

Why does my file processing cache miss when the file content has not changed?

If your file processing cache misses despite unchanged content, the hashing may not be path-independent. Using SHA-256 over actual file bytes instead of file paths ensures consistent cache hits across runs.