Skip to content

fix(models): stop OCR model re-downloading on refresh + honest voice cache indicator - #106

Merged
slaveofcode merged 1 commit into
developfrom
fix/voice-cache-indicator
Aug 1, 2026
Merged

fix(models): stop OCR model re-downloading on refresh + honest voice cache indicator#106
slaveofcode merged 1 commit into
developfrom
fix/voice-cache-indicator

Conversation

@slaveofcode

Copy link
Copy Markdown
Owner

What

  • OCR: ppu-paddle-ocr fetches its model from raw/media.githubusercontent.com (git-LFS). Those hosts weren't in the service-worker ml-models-cache rule, so the OCR model re-downloaded on every refresh. Added them to the CacheFirst urlPattern (alongside Hugging Face + jsDelivr).
  • Voice-to-Text: transformers.js fires the download progress bar even on cache hits, which looked like a re-download. Added a definitive modelCached check (caches.open('transformers-cache')) and the progress label now says 'Loading model from cache…' vs 'Downloading model (first time only)…'.

Audit (the actual ask: 'ensure other tools don't re-download after refresh')

Background-removal, ffmpeg, face-blur, upscale, object-remove all load same-origin from /models/*, which the worker serves cache-control: immutable, max-age=1yr → held by the HTTP cache across refreshes, no SW rule needed. OCR was the only outlier (cross-origin GitHub host).

Verify

  • npx vitest run → 592 passed
  • npm run lint → 0 errors
  • npm run build → success, precache clean

… re-download after refresh

- PaddleOCR fetches its model from raw/media.githubusercontent.com (git-LFS);
  those hosts weren't in the SW ml-models-cache rule, so the OCR model
  re-downloaded on every refresh. Add them to the CacheFirst urlPattern
  alongside Hugging Face + jsDelivr.
- VoiceToText: the transformers.js progress bar fires even on cache hits,
  which read as a re-download. Add a definitive modelCached check
  (caches.open('transformers-cache')) and label the bar accordingly.

Audit note: the other model tools (background-removal, ffmpeg, face-blur,
upscale, object-remove) load same-origin from /models/* served
'immutable, max-age=1yr' by the worker, so they cache on the HTTP layer and
need no SW rule.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ubfx4XocHcECaL8twp9zsr
@slaveofcode
slaveofcode merged commit b51a048 into develop Aug 1, 2026
1 of 2 checks passed
@slaveofcode
slaveofcode deleted the fix/voice-cache-indicator branch August 1, 2026 15:35
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.

1 participant