prismicio / javascript-kit

Development kit for the Javascript language
https://developers.prismic.io
106 stars 69 forks source link

ApiCache not used for API requests #69

Closed chriserwin closed 9 years ago

chriserwin commented 10 years ago

I assumed from the documentation that the ApiCache would be used to cache all requests to the API. However it seems the only thing being cached by ApiCache is the instance of the api itself.

The only request handler that seems to do any caching is the nodeJSRequest which sets up it's own requestsCache and doesn't make use of the ApiCache.

Unless I'm missing something, the ApiCache seems to be essentially useless as it's only used during initialization, and the ApiCache is created during initialization. So it seems as though nothing is ever retrieved from the cache, which defeats the purpose of the cache.

Did I miss something, or do something wrong?

erwan commented 9 years ago

Hi Chriserwin,

All requests should be cached, and in particular queries to the repository. After a quick look at the code I think you're right, it's a bug. I'll look in more details and fix it if necessary.

Note that this is mostly interesting for Node.js, because when used in the browser the cache will often be empty anyway.