Skip to content

feat: add stateless binary response caching for conversion endpoints#13

Merged
crisog merged 7 commits into
mainfrom
binary-endpoints-fs-cache
Mar 1, 2026
Merged

feat: add stateless binary response caching for conversion endpoints#13
crisog merged 7 commits into
mainfrom
binary-endpoints-fs-cache

Conversation

@crisog

@crisog crisog commented Mar 1, 2026

Copy link
Copy Markdown
Owner

Summary

Adds optional stateless, filesystem-backed caching for binary conversion responses in the server.

  • Introduces a cacache-based cache utility with TTL + size-cap retention
  • Caches binary conversion outputs in processMediaJob() and serves cache hits before queueing work
  • Uses stable cache keys from input bytes + job type + output extension + normalized params (excluding runtime-only paths)
  • Preserves endpoint parity by bypassing cache for uploadToS3//url flows and /media/info
  • Adds CACHE_* env/config/docs (CACHE_ENABLED, CACHE_DIR, CACHE_TTL_HOURS, CACHE_MAX_SIZE_MB)
  • Retention is enforced on startup/read/write paths (no background sweep timer)

Test Coverage

  • Added/expanded tests for cache hit/miss paths, key determinism, TTL + size eviction, metadata round-trip, disabled-cache behavior, and S3 bypass.
  • Validated with npm run typecheck, npm run test:app, and npm run test:integration (all passing).

@crisog

crisog commented Mar 1, 2026

Copy link
Copy Markdown
Owner Author

@cursor review

@cursor

cursor Bot commented Mar 1, 2026

Copy link
Copy Markdown

Skipping Bugbot: Bugbot is disabled for this repository. Visit the Bugbot dashboard to update your settings.

@crisog

crisog commented Mar 1, 2026

Copy link
Copy Markdown
Owner Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Free Tier Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

break;
}

await cacache.rm.entry(env.CACHE_DIR, oldest.key);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cache eviction never frees disk space

High Severity

All eviction paths (enforceCacheRetention, expired-entry removal in getCachedOutput) call cacache.rm.entry, which only deletes the index entry — the content-addressable blob remains on disk. Neither cacache.rm.content nor cacache.verify is ever called, so CACHE_MAX_SIZE_MB is effectively unenforced on the filesystem. Disk usage grows monotonically and is never reclaimed, which can eventually fill the volume.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed 045e99f

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@crisog crisog merged commit 5e4dd09 into main Mar 1, 2026
4 checks passed
@github-actions

github-actions Bot commented Mar 1, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant