Skip to content

Purge frontend cache before first load on version change + reload-and-clear command #5190

Description

@bramkragten

Part of the epic: home-assistant/epics#113 (home-assistant/frontend)

Problem

The companion app is a WKWebView with no service worker (App-Bound Domains are not configured), so it relies entirely on WKWebView's HTTP cache. After an HA update it can load a stale index.html that imports the previous build's hashed JS, which is now deleted → 404 → broken / white screen. Because there's no SW and the frontend bundle failed to load, the frontend can't self-heal on its own here.

Today's native mitigations are reactive (serverVersionDidChange) and time-based (the ~3-day cleanFrontendAssetCacheIfNeeded purge). They can lose the cold-start race — e.g. when the app and core update together and the new version was already recorded, no version-delta fires and the stale HTML loads first. (Matches #3738.)

Change

  • Proactively purge the frontend asset cache before the first WKWebView load whenever the stored server version differs from the last-seen version, closing the cold-start race (rather than reacting after the stale HTML has already loaded).
  • Add an external-bus command (e.g. frontend/reload_and_clear_cache) that clears the WKWebView caches and reloads, so the frontend's boot-recovery guard can delegate cache clearing to the native app. (Frontend side tracked under Frontend can fail to load after an update (stale cached index.html → deleted hashed JS 404) epics#113.)

Acceptance criteria

  • Cold-launching the companion app after an HA update loads the new frontend without a manual Settings → Companion App → Debug → Reset frontend cache.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions