Skip to content

fix(deploy): cache the PowerSync wasm and stop caching the SPA shell - #1205

Open
njbrake wants to merge 1 commit into
thunderbird:mainfrom
njbrake:pr6-static-asset-caching
Open

fix(deploy): cache the PowerSync wasm and stop caching the SPA shell#1205
njbrake wants to merge 1 commit into
thunderbird:mainfrom
njbrake:pr6-static-asset-caching

Conversation

@njbrake

@njbrake njbrake commented Aug 6, 2026

Copy link
Copy Markdown

Note: this PR description was drafted by Claude via back-and-forth with @njbrake. The reasoning and decisions are his; the prose is Claude's.

Two nginx caching gaps that pull in opposite directions.

/@powersync/ was matched by no location block, so PowerSync's wa-sqlite assets fell through to location / with no caching directives at all. That is roughly 17MB of content-hashed files revalidated on every boot, when they are as immutable as anything under /assets/.

index.html had the opposite problem. It is the shell that names the hashed entry chunk, so a cached copy pins a client to an old build after a deploy. It now sends no-cache, which still permits a conditional request, so the common case is a 304 rather than a re-download.

Deep links pick this up too: the SPA fallback is a URI, so nginx does an internal redirect and re-runs location matching, and a request for /settings ends up in the location = /index.html block.

_Note: this PR description was drafted by Claude via back-and-forth with @njbrake. The reasoning and decisions are his; the prose is Claude's._

Two nginx caching gaps that pull in opposite directions.

**`/@powersync/` was matched by no location block**, so PowerSync's wa-sqlite assets fell through to `location /` with no caching directives at all. That is roughly 17MB of content-hashed files revalidated on every boot, when they are as immutable as anything under `/assets/`.

**`index.html` had the opposite problem.** It is the shell that names the hashed entry chunk, so a cached copy pins a client to an old build after a deploy. It now sends `no-cache`, which still permits a conditional request, so the common case is a 304 rather than a re-download.

Deep links pick this up too: the SPA fallback is a URI, so nginx does an internal redirect and re-runs location matching, and a request for `/settings` ends up in the `location = /index.html` block.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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