jupyter / notebook

Jupyter Interactive Notebook
https://jupyter-notebook.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
11.38k stars 4.74k forks source link

Lack of Cache-control header on /api routes requires "cache-busting" on clients #4298

Open jameskoch opened 5 years ago

jameskoch commented 5 years ago
  1. The /api/contents route (and some other /api routes) do not include a Cache-control header in their response.
  2. They do include a Last-Modified header.

The combination of these two things triggers most browsers to cache the result for a while, requiring consumers of these endpoints to use "cache-busting" techniques like adding timestamps to the query string.

The heuristic used by most browsers to determine how long to cache a result w/ these headers is (Now - Last-Modified) / 10. So if I pull /api/contents for something that hasn't changed in ten hours, the browser will cache that result for one hour.

More details in https://github.com/nteract/nteract/issues/3850

takluyver commented 5 years ago

I haven't thought much about it, but I assume it makes sense to prevent caching of API responses (except maybe file contents?). PRs welcome.