-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enable control of cache behavior for source and query APIs #33
Conversation
f460ecd
to
338a08d
Compare
This very raw proposal that solves problem of cache control in most minimalistic way
I still left On the other hand current behavior is simply wrong. People may pass |
338a08d
to
4b0c421
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm tempted to stop inspecting headers
to determine the local cache settings, and let that be based on the localCache
prop alone. Do you think that would be OK? Presumably this would land in deck.gl v9.1.
It is nice that users who need to explicitly clear the cache can now do:
const cache = new Map()
const widgetSource = new WidgetQuerySource({localCache: { cache }, ... });
...
cache.clear();
src/sources/types.ts
Outdated
export type LocalCacheOptions = { | ||
canReadCache?: boolean; | ||
canStoreInCache?: boolean; | ||
cache?: Map<string, Promise<unknown>>; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming we plan to respect the definitions of HTTP CacheControl
headers, do we want to borrow their API too? This could be...
export type LocalCacheOptions = {
cache?: Map<string, Promise<unknown>>;
cacheControl?: ('no-cache' | 'no-store')[]
}
... which is nice because external users can find existing API documentation easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we are down to two options, I wouldn't use a nested cache
object and instead just provide these options directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, i would go in other direction.
We clearly have "domain" options (url params, post params) and meta params: cache, max url length, context, signal in near future hopefully.
I would separate those "meta" params into one object, so it's easy to pass it around between layers. Those spread operators tend to be tedious when you have to repeat them with more than handful of values in many places.
(look at old react-widgets model props).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough
d9b5c79
to
8bf459a
Compare
8bf459a
to
7c11e42
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks!
Add cache control parameters to sources and
query
API.detect caching from HTTP headers.Usage example: