Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

ios + sw: bypass cached disk.mjs after deploys

iOS app:
- Wipe WKWebsiteDataStore disk/memory/fetch caches and unregister stale
service worker registrations on every WebView creation. Cookies,
localStorage, and IndexedDB are preserved so the user stays logged in.
- Load the top-level URL with .reloadIgnoringLocalCacheData so the
initial request bypasses any leftover URL cache.

Without this, the in-app webview kept serving disk.mjs / bios.mjs from
the SW's stale-while-revalidate cache for up to an hour after a deploy,
which is why fresh telemetry/rotation fixes weren't reaching the phone.

sw.js:
- Bump CACHE_NAME ac-modules-v5 → v6 so existing browser SWs evict the
pre-fix disk.mjs (which had the wrong piece-log payload shape) on
next page load. Helps web users + the iPhone before its app update.

+30 -4
+29 -3
apple/aesthetic.computer/ContentView.swift
··· 112 112 config.userContentController.addUserScript(userScript) 113 113 config.userContentController.add(context.coordinator, name: "iOSAppLog") 114 114 config.userContentController.add(context.coordinator, name: "iOSApp") 115 + 116 + // 🧹 Clear cached JS modules and unregister stale service workers 117 + // before each app launch. The web app's service worker caches 118 + // /aesthetic.computer/*.mjs (boot, bios, disk, ...) with 119 + // stale-while-revalidate for up to an hour, which means freshly 120 + // deployed code can take a full launch cycle to reach the 121 + // device. Keep cookies/localStorage so the user stays logged in. 122 + let cacheTypes: Set<String> = [ 123 + WKWebsiteDataTypeDiskCache, 124 + WKWebsiteDataTypeMemoryCache, 125 + WKWebsiteDataTypeFetchCache, 126 + WKWebsiteDataTypeOfflineWebApplicationCache, 127 + WKWebsiteDataTypeServiceWorkerRegistrations, 128 + ] 129 + WKWebsiteDataStore.default().removeData( 130 + ofTypes: cacheTypes, 131 + modifiedSince: .distantPast 132 + ) {} 133 + 115 134 let webView = WKWebView(frame: .zero, configuration: config) 116 135 webView.backgroundColor = UIColor(red: grey, green: grey, blue: grey, alpha: 1) 117 136 webView.isOpaque = false 118 137 // webView.navigationDelegate = context.coordinator 119 138 webView.uiDelegate = context.coordinator 120 139 webView.customUserAgent = "Aesthetic" 121 - 140 + 122 141 // Add a script message handler to handle messages from JavaScript 123 142 AppDelegate.shared?.appWebView = webView // Set the shared appWebView 124 143 return webView 125 144 } 126 - 145 + 127 146 func updateUIView(_ webView: WKWebView, context: Context) { 128 147 // let testHTML = "<html><script>window.ontouchstart = () => { console.log('hi'); const a = document.createElement('a'); a.href = 'https://example.com'; a.innerText = 'OKAY'; document.body.appendChild(a); a.click(); }</script><body></body></html>" 129 148 // webView.loadHTMLString(testHTML, baseURL: nil) 130 - let request = URLRequest(url: URL(string: url)!) 149 + // 🚫 .reloadIgnoringLocalCacheData makes the initial top-level 150 + // request bypass any leftover URL cache, so a redeploy is 151 + // visible after a single app relaunch. 152 + let request = URLRequest( 153 + url: URL(string: url)!, 154 + cachePolicy: .reloadIgnoringLocalCacheData, 155 + timeoutInterval: 30 156 + ) 131 157 webView.load(request) 132 158 } 133 159
+1 -1
system/public/sw.js
··· 1 1 // Aesthetic Computer Service Worker 2 2 // Caches JavaScript modules for faster subsequent loads 3 3 4 - const CACHE_NAME = 'ac-modules-v5'; // Bump version to force SW update 4 + const CACHE_NAME = 'ac-modules-v6'; // Bump to invalidate cached disk.mjs/bios.mjs after the piece-runs telemetry shape fix 5 5 const CACHE_DURATION = 60 * 60 * 1000; // 1 hour in ms (dev-friendly) 6 6 7 7 // Critical modules to precache on install