Repository navigation
fix(wmo): serve fresh present weather from per-city feed - #13
Merged
Merged
Conversation
Drop the unstable_cache wrappers whose stale-while-revalidate served stale weather on first load. Fetch present observations from the per-city endpoint instead of the ~71 KB aggregate feed, keep presentAll for that feed, and derive icons from wxImageCode.
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.
Problem
Visiting a cached city served stale weather on first load; fresh data appeared only after a refresh. Root cause:
unstable_cacheuses stale-while-revalidate — the request that detects expiry gets the stale value and refreshes in the background.Also,
present()downloaded the wholepresent.xmlfeed (~71 KB gzip) and discarded all but one city.Changes
getCachedPresent/getCachedForecasts; the dynamic weather page fetches raw data on each render. Keep the 24 hunstable_cachefor country/city lists.present_{cityId}.json(~180 B). KeeppresentAll(locale)for the aggregate feed.wxImageCode, removing theiconNumround-trip.Verification
npm run lint— 0 errors (2 pre-existing<img>warnings)npm run format:check— cleannpm run build— compiled, TypeScript passeden,de,zh-Hant,ko; empty-observation and live cities; rendered temps/icons match WMONote
present_{cityId}.jsonis undocumented by WMO (verified against the official dataguide) but live, CDN-cached, and field-identical to the aggregate feed. It is used without fallback per project decision.