Webview caching enhancements#1066
Conversation
Agressively clears the cache when reloading uses Etag headers to determine if a new version of the web app is needed when the view becomes active Adds the "reload" icon back to the Drawer menu when the webview is active Fixes openhab#1063 Signed-off-by: Dan Cunningham <dan@digitaldan.com>
There was a problem hiding this comment.
Pull request overview
Improves how the iOS app’s embedded Main UI webview refreshes and invalidates cached content, aiming to ensure the latest UI is shown after reloads/app re-activation (Fixes #1063).
Changes:
- Add ETag-based change detection (HEAD requests + persisted ETag cache) to decide when to reload web content.
- Make “reload app” perform a more aggressive webview cache bypass/clear during forced loads.
- Reintroduce a reload indicator in the drawer’s “Home” item when the webview is the active view.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| openHAB/OpenHABWebViewController.swift | Adds app-active reload checks, ETag-driven reload decisions, and forced cache bypass/clearing behavior. |
| openHAB/OpenHABRootViewController.swift | Tracks whether the webview is the current view and exposes that state to SwiftUI. |
| openHAB/DrawerView.swift | Adds CurrentViewState env object and shows a reload icon when webview is active. |
| OpenHABCore/Sources/OpenHABCore/Util/LoggerExtension.swift | Adds dedicated logging categories for ETag cache/checker. |
| OpenHABCore/Sources/OpenHABCore/Util/HTTPClient.swift | Extends requests to support non-GET methods (needed for HEAD). |
| OpenHABCore/Sources/OpenHABCore/Util/ETagChecker.swift | New actor to perform HEAD requests and compare/persist ETags. |
| OpenHABCore/Sources/OpenHABCore/Util/ETagCache.swift | New actor implementing persisted ETag storage. |
1fb88cd to
cbd388e
Compare
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
cbd388e to
75b8490
Compare
|
Oof, i should know better then to click on the "suggested" edit button, i somehow could not update my local branch nor push new changes (b/c i couldn't update my local branch!) , hence the force pushed updates here. |
|
@timbms @TAKeanice let me know if this looks 👍 👎 to merge, thanks! |
|
@digitaldan I am only using WebView marginally. I will not be able to test it myself. I delegated it to Claude: (:-) What it does When the app returns from background or the user navigates to the webview, instead of always reloading (slow, flicker) or never reloading Additionally, the drawer menu shows a refresh icon next to "Home" when the webview is active, and force-reload clears WKWebView's disk/memory What's good
Concerns
Verdict Solid feature, well-tested, solves a real UX problem. The ETag infrastructure is reusable. The CurrentViewState feels a bit heavy for what it |
|
I think this introduced a regression where the iOS app reloads Main UI every time it goes into the foreground, and not just on app start, which is super annoying as you be back at the root of the UI. |
Could be related to this concern:
|
|
I think this thoughts is right. |
|
Sorry for the late follow up, did this ever get resolved? Its not happening for me, so i'm curious if someone fixed this in another PR (that i can't find)/ |
|
No, this is still an issue. I'll PM you a screen capture over Slack. |
Agressively clears the cache when reloading
uses Etag headers to determine if a new version of the web app is needed when the view becomes active Adds the "reload" icon back to the Drawer menu when the webview is active
Fixes #1063