Which Jamstack strategy ensures accurate local dates without stale caching?
27K reputation · 26 Aug 2020, 16:40 UTC
Goal
To display event dates in the user’s local time on a Jamstack site while keeping the build process simple and ensuring SEO friendliness.
Constraints & Uncertainty
Jamstack sites are pre‑rendered; static pages may hard‑code dates, causing stale or incorrect times when users visit from different time zones. Client‑side conversion via Intl.DateTimeFormat or libraries like date‑fns‑tz exposes raw UTC timestamps and adds runtime overhead. Serverless or edge functions can perform conversion per request, but they must rely on headers such as Accept-Language or custom X‑Timezone, and may be limited by caching layers.
Questions
Which approach—build‑time locale‑specific rendering, client‑side conversion, or edge‑function conversion—offers the best balance of accuracy, performance, and SEO for high‑traffic Jamstack sites?
What are the practical trade‑offs in cache invalidation and revalidation when using each method?
Can edge functions reliably detect a user’s timezone from HTTP headers without compromising privacy or performance?