From 944a52f0e33087dafba383edb3d97ec19a06d361 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 28 Jun 2026 03:50:53 -0400 Subject: fix: key the cache on all response-shaping settings wttrin--make-cache-key keyed only on location and unit system, but the request body also depends on wttrin-display-options and wttrin-default-languages. Changing display options or language mid-session served the old cached response, and the staleness header then claimed it was current for the new settings. The key now includes every setting that shapes the response. Cache-key tests rewritten to assert behavior (distinct key per varying setting, stable key for identical settings) instead of an exact key string. --- wttrin.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'wttrin.el') diff --git a/wttrin.el b/wttrin.el index 3d543ed..cdef10a 100644 --- a/wttrin.el +++ b/wttrin.el @@ -1236,8 +1236,13 @@ coordinates from a geolocation command." (wttrin--display-weather query raw-string error-msg display address))))))) (defun wttrin--make-cache-key (location) - "Create cache key from LOCATION and current settings." - (concat location "|" (or wttrin-unit-system "default"))) + "Create a cache key from LOCATION and every setting that shapes the response. +Includes the unit system, display options, and Accept-Language, so changing any +of them produces a distinct key rather than serving a stale-format response." + (format "%S" (list location + (or wttrin-unit-system "default") + (or wttrin-display-options "") + wttrin-default-languages))) (defun wttrin--get-cached-or-fetch (location callback) "Get cached weather for LOCATION or fetch if not cached. -- cgit v1.2.3