Repository navigation
Make apps installable with a web app manifest - #393
Conversation
Apps get a web app manifest named after the app, so browsers offer to install them as desktop and home-screen apps. The runtime links it from every HTML page and serves it at /manifest.webmanifest, listing the app's favicon.svg, apple-touch-icon.png and favicon.png. A page that links its own manifest, or an app that serves one, keeps its own. The app name is part of the published app snapshot, written at deployment by the control plane and the agent.
| const result = new Response(rewritten.body, rewritten); | ||
| result.headers.delete("content-length"); |
There was a problem hiding this comment.
Cached pages miss manifest links
The rewritten HTML keeps the original etag. A returning visitor may already have the same file cached without the new link. After deployment, serveAsset matches that unchanged tag and returns 304 before linkManifest runs, so a normal reload keeps the page without a manifest link.
Give rewritten HTML a different cache tag and use it when checking conditional requests. Deleting the tag here alone would not fix the earlier 304 response.
There was a problem hiding this comment.
This only affects pages a browser cached before this release: revalidation keeps their copy until the file changes with a later deployment. Every response produced by this runtime carries the link, so the ETag stays stable for its representation from here on. No change.
There was a problem hiding this comment.
I see the rollout is limited to clients with a pre-release cached page. One detail: serveAsset handles If-None-Match before linkManifest, so those clients get a 304 with the old HTML; because the source ETag remains unchanged, repeated revalidations can keep that copy indefinitely—not just until the next reload. If that legacy-cache gap is an accepted tradeoff, understood, but it does not self-correct without an asset change.
There was a problem hiding this comment.
Accepted tradeoff: those copies refresh when the file changes with a later deployment.
| if ( | ||
| app.displayName && | ||
| url.pathname === manifestPath && | ||
| request.method === "GET" && | ||
| !app.manifest[manifestPath] | ||
| ) | ||
| return browserPolicy( | ||
| await webManifest(environment, app, app.displayName), |
There was a problem hiding this comment.
When an app worker serves /manifest.webmanifest without a static file at that exact path, this branch returns the generated manifest before calling the worker. The app loses its custom icons, launch path, and other install settings, contrary to the promised app override.
Preserve app-provided manifest responses while still bypassing generic HTML fallbacks.
There was a problem hiding this comment.
Intended, and the inverse of the previous finding: answering before the app is what keeps catch-all routes and _redirects fallbacks from hiding the manifest. An app that generates its manifest links it from its pages under any other path, and a static /manifest.webmanifest file is served as is. The docs PR describes both.
There was a problem hiding this comment.
Thanks for clarifying. You're right: I treated a worker-generated response at /manifest.webmanifest as an override, but the intended contract reserves that URL for the generated manifest unless the app ships a static asset there. Serving it before the worker is what prevents catch-all routes and rewrite fallbacks from masking it; apps that generate their own manifest can link it under another path. This finding was based on the wrong assumption and should be withdrawn.
## Summary - HTML assets that receive the manifest link now use the ETag `"<hash>-manifest"` instead of the uploaded file's `"<hash>"`. - A browser that cached a page before #393 sends the old ETag, gets the linked page with `200` and can install the app. Previously it received `304` and kept its copy without the link for as long as the file stayed unchanged, so redeploying an app with unchanged HTML did not make it installable for returning visitors. - Copies cached with the link still revalidate with `304`. ## Checks - `RUN_DYNAMIC_TESTS=1` runtime suite on pinned celld (24 passed), extended with the old-ETag and new-ETag revalidation cases. - `RUN_CLOUDFLARE_TESTS=1` runtime suite in workerd (73 passed). - `pnpm check`. <!-- greptile_comment --> <!-- greptile_summary --> <h2><a href="https://app.greptile.com/api/retrigger?id=119530182&sig=788a85a7d46d490fb8508ad172e5ebff20eecde5e1626d230b3f4b0420657463"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a><a href="https://app.greptile.com/-/switch-tenant?tenant=mendra&next=%2Fwidefleet%2Fwidefleet%2Fpull%2F402&utm_source=greptile_review&utm_medium=github&utm_campaign=view_in_greptile"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img alt="View in Greptile" src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2" align="right"></picture></a>Confidence Score: 5/5</h2> <!-- greptile-impact-verdict --> The PR appears safe to merge; the previous cache issue is fixed. <details open><summary><h3>Summary</h3></summary> HTML assets use a separate ETag for pages eligible for the manifest link, so browsers replace older cached copies. - Manifest-linked app pages use a separate cache tag. </details> <!-- greptile_confidence_score:5 --> <sub>Reviews (2) · Last reviewed commit: ["Choose the page ETag after header rules"](cbd1cae) · [Reviewed by Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub> <!-- /greptile_comment -->
## Summary - Adds **Install apps on phones and computers**: every Widefleet app installs on iPhone, iPad, Android, Mac and Windows from the same deployment. Covers the install steps per device (iPhone steps match the **Open app** dialog on Home), the installed name, icons rendered from `favicon.svg`, own icons or manifest, and that name and icon are readable without signing in. - **App development** says that every app installs on phones and computers and links the guide, so readers looking for a phone app find it. - **Applications** keeps a short section that links the guide. Documents #393, #403 and #405, released in v0.7.23. ## Checks - `blume validate` and Oxfmt pass.
Summary
/manifest.webmanifestwith the app's Widefleet name,start_urlandscope/,display: standalone, and the icons the app ships:favicon.svg(sizes: any) plusapple-touch-icon.pngandfavicon.pngwith their real PNG dimensions.crossorigin="use-credentials", because browsers fetch manifests without cookies otherwise and app pages require sign-in./manifest.webmanifestitself keeps its response.displayName), written at deployment by the Cloudflare publisher and the agent. A rename reaches the manifest with the next deployment.Checks
RUN_DYNAMIC_TESTS=1runtime suite on pinned celld (24 passed), including the new manifest link and manifest test.RUN_CLOUDFLARE_TESTS=1runtime suite in workerd (73 passed), including the new manifest test.cargo test -p platform-core -p platform-agent,cargo fmt --check,pnpm check.Docs: #394
The PR should preserve manifests served by app workers before merging.
Findings
Summary
Adds generated web app manifests and links them from HTML pages.
Reviews (2) · Last reviewed commit: "Serve the platform manifest before rewri..." · Reviewed by Greptile