content-hash-cache-pattern

Cache file processing results using content hashes as keys.

7|Updated Mar 4, 2026
One-click install
npx skills add https://github.com/Davie521/claude-skills --skill content-hash-cache-pattern-davie521
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: content-hash-cache-pattern
Source: https://github.com/Davie521/claude-skills/tree/main/plugins/web/skills/content-hash-cache-pattern
Command: npx skills add https://github.com/Davie521/claude-skills --skill content-hash-cache-pattern-davie521

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Cache expensive file processing results using content hashes as cache keys, enabling path-independent caching that survives moves and renames.

Core Features & Use Cases

  • Content-hash based cache key: uses file content to identify cache entries, so moves/renames do not invalidate the cache.
  • File-based cache storage: stores entries as {hash}.json for O(1) lookups with no index file required.
  • Service-layer design: keeps processing functions pure and uses a separate cache service to handle reads/writes and invalidations.
  • Use cases: PDF parsing, OCR, image analysis, or text extraction in batch pipelines that run across sessions.

Quick Start

Enable content-hash caching on a directory of PDFs and run the extractor to see cache hits.

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 cache expensive PDF parsing and OCR results across different sessions?

Caching expensive file processing like PDF parsing or OCR uses a content hash as the cache key to identify files. This approach enables path-independent caching that survives file moves or renames across different processing sessions.

What is the best way to cache file processing results when files are moved or renamed?

Using a content-hash-based cache key is the best way to cache file processing results when files are moved or renamed. The cache entries are stored as individual JSON files named by hash, providing O(1) lookups without needing an index file.

Does content-hash caching require a separate service to handle file processing?

Yes, this content-hash caching approach uses a service-layer design that requires a separate cache service to handle reads, writes, and invalidations. This design keeps your file processing functions pure and separate from cache management logic.

How do I implement a content hash cache for batch text extraction pipelines?

You implement a content hash cache for batch text extraction pipelines by pairing a pure processing function with a separate cache service. The service computes the file's content hash, checks for a matching JSON file, and handles cache hits or misses accordingly.

Can I use file-based JSON storage for caching image analysis results?

Yes, you can use file-based JSON storage for caching image analysis results. The system stores each cache entry as a JSON file named by the content hash, enabling O(1) lookups for your image processing pipelines without requiring an index file.

Why does my file cache miss when processing the same file from a new directory path?

Your file cache misses when processing the same file from a new directory path because path-based cache keys become invalidated upon moving files. Using a content-hash-based cache key solves this by identifying files solely by their content, ensuring cache hits regardless of location.