nextstrain / nextstrain.org

The Nextstrain website
https://nextstrain.org
GNU Affero General Public License v3.0
87 stars 49 forks source link

upstream: Add a Cache-Control header to resource responses #782

Closed tsibley closed 5 months ago

tsibley commented 5 months ago

This permits private caching (e.g. by browsers), like now, but instructs them to always check for updates (revalidate) before using the cached response (unlike now). Prior to this, browsers would use their own heuristics to figure out when to revalidate which could lead to staleness and user confusion.

This new caching policy doesn't save a request/response cycle, but it does save response transfer time when a cached response can be used. It also forbids using the cached response when the browser is offline, though I'm not sure we care about that use case (and not sure other bits of nextstrain.org support it, like the Auspice client).

This affects the RESTful API and Charon API endpoints for datasets and narratives, as well as the endpoints for a group's overview and logo.

Resolves https://github.com/nextstrain/nextstrain.org/issues/707.

Checklist