Skip to content

fix(wmo): serve fresh present weather from per-city feed - #13

Merged
markmybytes merged 1 commit into
mainfrom
fix/fresh-present-weather
Nov 30, 2026
Merged

markmybytes merged 1 commit into
mainfrom
fix/fresh-present-weather

Conversation

@markmybytes

Copy link
Copy Markdown
Owner

Problem

Visiting a cached city served stale weather on first load; fresh data appeared only after a refresh. Root cause: unstable_cache uses stale-while-revalidate — the request that detects expiry gets the stale value and refreshes in the background.

Also, present() downloaded the whole present.xml feed (~71 KB gzip) and discarded all but one city.

Changes

  • Drop getCachedPresent / getCachedForecasts; the dynamic weather page fetches raw data on each render. Keep the 24 h unstable_cache for country/city lists.
  • Read present observations from present_{cityId}.json (~180 B). Keep presentAll(locale) for the aggregate feed.
  • Derive icons from the two-digit wxImageCode, removing the iconNum round-trip.
  • Preserve empty-observation cities (render N/A, not 500).

Verification

  • npm run lint — 0 errors (2 pre-existing <img> warnings)
  • npm run format:check — clean
  • npm run build — compiled, TypeScript passed
  • Server smoke tests: 200 for en, de, zh-Hant, ko; empty-observation and live cities; rendered temps/icons match WMO
  • 240-city icon comparison across 12 locales: 0 mismatches

Note

present_{cityId}.json is 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.

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.
@markmybytes
markmybytes merged commit 3c90946 into main Nov 30, 2026
2 checks passed
@markmybytes
markmybytes deleted the fix/fresh-present-weather branch November 30, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant