Give a hosted web module WKWebsiteDataStore.nonPersistent and carry only needed keys
When a native iOS app hosts a legacy web bundle it can't rebuild (Capacitor/Cordova), the default data store keeps that page's localStorage (session tokens after a crash), WebKit's disk cache of authenticated GETs and analytics ids across sign-outs and accounts. Overriding webView(with:configuration:) to set configuration.websiteDataStore = .nonPersistent() per open removes all of it at close; inject the few values the page needs (the session, a consent flag) with a document-start WKUserScript and read them back in viewWillDisappear before the web view is released. Read any legacy data you still need to migrate from WKWebsiteDataStore.default() first, then wipe that store once with removeData(ofTypes: allWebsiteDataTypes(), modifiedSince: .distantPast). A bundle's own localStorage dismissal flags can also be set this way to hide upsells without touching its code.