Apply app updates automatically and survive proxy caching
All checks were successful
Verify and publish Calio container / build-and-push (push) Successful in 29s

- Check for a new service worker on every return to the foreground and
  every 30 minutes; apply it in the background or just after launch,
  never with unsynced edits or an open sheet. The Update prompt remains.
- Register the worker at extension-less /sw (no-cache), so proxies that
  cache *.js regardless of headers cannot hide updates
- Return 404 for missing files instead of the HTML shell
- Tests for the static routes; smoke test covers /sw; document the Nginx
  Proxy Manager "Cache Assets" pitfall

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-10-22 11:19:30 -07:00
parent bb0bc430aa
commit 8f6981c8a2
7 changed files with 190 additions and 40 deletions

View file

@ -46,6 +46,8 @@ chmod 770 /mnt/user/appdata/calio
These commands affect only Calio's directory. If you choose another path, use that path instead. Calio does not implement `PUID`/`PGID` environment variables: Docker's `--user` selects the identity. If migrating existing data, ensure its database and sidecar files are also writable by the chosen identity while Calio is stopped. The standalone image otherwise defaults to UID 1000.
If you use Nginx Proxy Manager, leave **Cache Assets** off for this host. It caches every `.js` file for hours regardless of the app's `no-cache` headers, which delays app updates. Calio already caches its own versioned assets on devices. (Current builds also load the service worker from the extension-less `/sw`, so such a cache cannot block updates, but a stale cache still wastes a day on older clients.)
Configure your HTTPS reverse proxy to forward **all paths** to `http://<Unraid-IP>:3080`, or `http://calio:3000` on a shared Docker network. Leave `/api` intact. Open the public HTTPS address for sign-in and PWA installation. The upstream HTTP port alone does not provide the secure cookies or service worker origin needed by a phone PWA.
On iPhone, use Safari → Share → **Add to Home Screen**. On Android, use Chrome → **Install app** / **Add to home screen**. Sign in online once and allow the initial sync to finish before testing offline use.
@ -63,7 +65,7 @@ docker cp calio:/data/backups/before-update.sqlite ./calio-backup.sqlite
Use a new backup filename each time and copy it off the server. Do not copy only the live `calio.sqlite` file while Calio is writing: committed data can still be in its WAL sidecar. See the [README](../README.md#persistent-data-updates-and-backups) for restoration and device-cache considerations.
After a successful main build, select **Check for Updates → Update** on Unraid's Docker page. Unraid pulls `latest` and recreates the container with the saved port, path and variable settings. The PWA offers its own **Update** prompt after reconnecting; queued offline edits must sync before accepting it.
After a successful main build, select **Check for Updates → Update** on Unraid's Docker page. Unraid pulls `latest` and recreates the container with the saved port, path and variable settings. Devices then update themselves: the app checks for a new version each time it returns to the foreground, downloads it in the background, and switches over at a moment that cannot interrupt you (while it is in the background, or just after you open it). It waits while edits are unsynced or a sheet is open. An **Update** prompt is also shown for switching immediately.
For a specific build, replace `:latest` in the repository field with its full commit SHA or published version tag. Database schema checks prevent an older app from opening a newer unsupported schema; a rollback across schema changes may need the matching database backup.