Skip to content

Promote to production: same-origin HF model proxy - #91

Merged
slaveofcode merged 2 commits into
mainfrom
develop
Aug 1, 2026
Merged

Promote to production: same-origin HF model proxy#91
slaveofcode merged 2 commits into
mainfrom
develop

Conversation

@slaveofcode

Copy link
Copy Markdown
Owner

Proxies HF model weights same-origin with immutable caching so the Whisper model stops re-downloading on refresh.

🤖 Generated with Claude Code

Kresna and others added 2 commits August 1, 2026 19:14
The Whisper model re-downloaded on every refresh: transformers.js fetches weights
from huggingface.co, which 302-redirects large files to a CDN, and neither the
browser nor Workbox reliably caches redirected cross-origin responses.

Add a /hf/* proxy to the edge Worker that resolves the redirect server-side and
returns the bytes same-origin with 'cache-control: immutable' (+ Cloudflare edge
cache). Point transformers.js env.remoteHost at it (skipped on localhost dev).
The browser HTTP-caches the same-origin immutable response — the same mechanism
that already makes the self-hosted OCR model cache reliably — so it survives
refreshes. Falls back to the default host if env can't be set.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
fix(voice-to-text): proxy HF model weights same-origin so they cache
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 1, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
goodwebtools f99c542 Aug 01 2026, 12:22 PM

@slaveofcode
slaveofcode merged commit 4630a24 into main Aug 1, 2026
2 of 3 checks passed
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