content-hash-cache-pattern

Cache file processing results using SHA-256 content hashes.

Updated Mar 4, 2026
One-click install
npx skills add https://github.com/Fabio29T/Everything-Claude --skill content-hash-cache-pattern-fabio29t
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: content-hash-cache-pattern
Source: https://github.com/Fabio29T/Everything-Claude/tree/main/docs/zh-CN/skills/content-hash-cache-pattern
Command: npx skills add https://github.com/Fabio29T/Everything-Claude --skill content-hash-cache-pattern-fabio29t

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill caches the results of expensive file processing tasks (like PDF parsing or text extraction) using content hashes, ensuring that cached data remains valid even if files are moved or renamed, and automatically invalidates when content changes.

Core Features & Use Cases

  • Path-Independent Caching: Uses SHA-256 hash of file content as the cache key, making it resilient to file renames or moves.
  • Automatic Cache Invalidation: Cache entries are automatically invalidated when the file content changes.
  • Service Layer Separation: Keeps core processing functions pure by handling caching logic in a separate wrapper.
  • Use Case: When building a document processing pipeline that involves computationally intensive steps like extracting text from PDFs or analyzing images, this pattern ensures that identical files are processed only once, significantly speeding up batch operations and reducing redundant computation.

Quick Start

Use the content-hash-cache-pattern skill to extract text from the file located at /path/to/document.pdf, utilizing the cache if available.

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 file processing results when files are renamed or moved?

Use SHA-256 content hashing to cache expensive file processing results. By hashing file contents as cache keys, the cached data remains valid even if files are moved or renamed, ensuring consistent retrieval.

What is the best way to invalidate a document processing cache when file content changes?

Content-hash caching provides automatic cache invalidation when file content changes. Since the SHA-256 hash of the file content serves as the cache key, any modification to the file generates a new hash.

How do I speed up batch PDF parsing and text extraction for identical files?

Speed up batch PDF parsing and text extraction by caching results with content hashes. This pattern ensures identical files are processed only once, significantly reducing redundant computation in document processing pipelines.

Can I use Python hashlib and dataclasses to manage a file processing cache?

Yes, you can use Python hashlib for SHA-256 hashing and dataclasses for cache entry management. This approach separates caching logic in a wrapper, keeping core processing functions pure.

Does path-independent caching work for image analysis pipelines?

Yes, path-independent caching works for image analysis pipelines. Using SHA-256 hashes of file contents as cache keys makes the cache resilient to file renames or moves, applicable to any expensive file processing.