fix: cache open-meteo and timezone requests for offline use - #191
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Going offline loaded the app shell but no forecast data.
The offline cache is the Workbox runtime-caching config, which matches by URL prefix. Winds aloft used to be fetched from
/api/rap, covered by a 4-hourNetworkFirstrule. b9d12e6 removed rucsoundings support and deleted that rule, but the replacement source (Open-Meteo, at/api/openmeteo/forecast) never had one.That made the failure total rather than partial:
getWeatherawaitsloadWindsAloft()before anything else, so when that request throws offline the thunk rejects and alerts, TAF, and the NWS forecast never load — even though those endpoints were still cached./api/openmeteo.*→NetworkFirst, 4 hours, matching the other weather caches. Covers both the winds-aloft and hourly-weather calls./api/timezone.*→NetworkFirst, 7 days. Also uncached; outside the US it is the only timezone source, so offline fell back to "using local time"./api/weatherrule — two identical entries existed and the second was unreachable.Verified with a fresh
pnpm build: the generatedservice-worker.jsregistersapiOpenMeteoCacheandapiTimezoneCache, with a singleapiWeatherCacheroute.Note: this only takes effect once the new service worker activates and the app is loaded online once to populate the cache.