Skip to content

feat(directus-client): prune stale asset cache entries - #289

Merged
remihuigen merged 8 commits into
mainfrom
feat/cache-prune
Sep 6, 2026
Merged

feat(directus-client): prune stale asset cache entries#289
remihuigen merged 8 commits into
mainfrom
feat/cache-prune

Conversation

@remihuigen

@remihuigen remihuigen commented Sep 6, 2026

Copy link
Copy Markdown
Member

Summary

  • Add opt-in pruning for stale Directus asset-cache entries on storage backends without native TTL enforcement.
  • Add throttled, best-effort request-triggered cleanup and export the reusable prune task handler.
  • Preserve ocache lifetime semantics, namespace boundaries, and anonymous asset-cache security.

Final implementation

The only pruning configuration is:

prune: {
  enabled: boolean;
  onRequest: boolean;
  interval: number;
}

Request-triggered pruning is owned by the Nitro application state and remains opt-in, throttled, single-flight, and failure-contained. The reusable prune task is exported by the package, but Nitro task ownership is consumer-side: consumers explicitly register and schedule it when needed. There is no task.enabled or task.schedule configuration.

Pruning derives the asset-cache namespace through public ocache.resolveCacheKeys(). Nitro/Unstorage owns key normalization and storage scoping. Entries are read and deleted through the existing ocache blob adapter: malformed or unusable decoded entries are removed, while backend read failures are skipped and retained for a later attempt.

The filesystem-backed E2E uses real Nitro storage and a deterministic local upstream, and proves stale entries are pruned while fresh entries and unrelated keys remain.

Validation

  • Focused asset-cache unit tests pass.
  • Filesystem pruning E2E passes.
  • corepack pnpm typecheck passes.
  • corepack pnpm lint:fix and corepack pnpm format pass.
  • corepack pnpm test passes.
  • corepack pnpm build passes.

Closes #253

@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

🦋 Changeset detected

Latest commit: e354627

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@onderwijsin/nuxt-directus-client Minor
@onderwijsin/nuxt-directus-config Minor
@onderwijsin/nuxt-directus-sitemaps Patch
@onderwijsin/nuxt-directus-prerenderer Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@remihuigen
remihuigen added this pull request to the merge queue Sep 6, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue because a pull request earlier in the stack was removed Sep 6, 2026
@remihuigen
remihuigen added this pull request to the merge queue Sep 6, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue because a pull request earlier in the stack was removed Sep 6, 2026
@remihuigen
remihuigen disabled the stack merge September 6, 2026 21:24
@remihuigen
remihuigen added this pull request to the merge queue Sep 6, 2026
@remihuigen
remihuigen removed this pull request from the merge queue due to a manual request Sep 6, 2026
@remihuigen
remihuigen added this pull request to the merge queue Sep 6, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue because a pull request earlier in the stack was removed Sep 6, 2026
@remihuigen
remihuigen added this pull request to the merge queue Sep 6, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue because a pull request earlier in the stack was removed Sep 6, 2026
Base automatically changed from fix/asset-handlers to main September 6, 2026 22:02
@remihuigen
remihuigen added this pull request to the merge queue Sep 6, 2026
Merged via the queue into main with commit 1673d1c Sep 6, 2026
14 checks passed
@remihuigen
remihuigen deleted the feat/cache-prune branch September 6, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(directus-client): prune stale asset cache entries on non-TTL storage

1 participant