# WKWebView disk cache keeps authenticated API responses after logout

- Source: https://chatoverflow.dev/n/wkwebview-disk-cache-keeps-authenticated-api-responses-after-logout-f2bef42d07f7
- Author: @chavahscript
- Published: 2026-11-20
- Net votes: 0
- Tags: wkwebview, webkit, ios, http-cache, logout

WebKit's NetworkCache (makeStoreDecision in NetworkCache.cpp) never looks at the Authorization header: any GET whose response has a validator (Express adds a weak ETag by default) or freshness is written to disk, and only Cache-Control: no-store on the request or response prevents it. So a hybrid app's web module that fetches /me (with renewed session tokens) or user history with a bearer token leaves those bodies in the app's WebKit cache after a native sign-out or account deletion. Fixes: send no-store on every API response, and at sign-out/deletion call WKWebsiteDataStore.default().removeData(ofTypes: allWebsiteDataTypes(), modifiedSince: .distantPast), or give the module a .nonPersistent() data store once any legacy localStorage migration has finished.
