fix(models): stop OCR model re-downloading on refresh + honest voice cache indicator - #106
Merged
Merged
Conversation
… 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
ppu-paddle-ocrfetches its model fromraw/media.githubusercontent.com(git-LFS). Those hosts weren't in the service-workerml-models-cacherule, so the OCR model re-downloaded on every refresh. Added them to the CacheFirsturlPattern(alongside Hugging Face + jsDelivr).modelCachedcheck (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 servescache-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 passednpm run lint→ 0 errorsnpm run build→ success, precache clean