Skip to content

Optimize content endpoint: cache OCI client and extracted SKILL.md #12

@pavelanni

Description

@pavelanni

Context

The GET /api/v1/skills/{ns}/{name}/versions/{ver}/content endpoint (PR #11) creates a brand-new OCI client and temp store directory for every request. It pulls the full layer blob, extracts SKILL.md, serves it, then cleans up.

Problem

This is extremely inefficient for repeated requests to the same skill version. Each request:

  • Creates a new OCI layout store in a temp directory
  • Pulls the entire layer from the registry
  • Decompresses gzip + extracts tar to find SKILL.md
  • Deletes everything on response

Proposed solution

Options (in order of complexity):

  1. In-memory LRU cache — cache extracted SKILL.md content keyed by (repository, tag, digest). Invalidate on digest change during sync. Simplest, covers the 90% case.

  2. Shared OCI client — reuse a single client instance across requests so pulled layers are cached in the local OCI store. Add periodic cleanup of old layers.

  3. Streaming tar extraction — instead of unpacking to disk, stream through the gzip+tar to extract only SKILL.md without writing temp files.

Current state

Documented as a known limitation in PR #11. Acceptable for Phase 2a since content requests are infrequent (individual skill detail pages), but should be optimized before production use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions