zooniverse / panoptes-javascript-client

A Javascript client for accessing the Panoptes API
https://zooniverse.github.io/panoptes-javascript-client
Apache License 2.0
6 stars 6 forks source link

API responses can't be cached by browsers or shared caches #250

Open eatyourgreens opened 1 day ago

eatyourgreens commented 1 day ago

https://github.com/zooniverse/panoptes-javascript-client/blob/8157794dfacfbc1f5d41c5730b2f47aae6fc013a/lib/auth.js#L49-L50

The auth client automatically injects an Authorization header into every request here. That's convenient for developers, who don't need to remember to add auth headers by hand.

However, responses to auth'ed requests can't be cached by shared caches or browsers (to protect end user privacy) and are sent with maxage=0. This means that large public resources, like classification workflows, can't be cached and must be requested on every use, even though they don’t require auth headers and could be served via a CDN.

eatyourgreens commented 1 day ago

I think the API client gets around this by maintaining its own internal resource cache, but that is also broken.