Can not cache getEntries

I just implemented caching with redis.

But i see in the Contentful/Client.php that when getEntries($query) is called, the caching is not used…

I dont understand why multiple entries could not be cached…

I am always using the getEntries function since i what to retrieve all entry related to a specific content-type and i need those to be cached…

Thanks

Hey Olivier,

caching with getEntries is not enabled for 2 reasons:

  • For architectural reasons, only content types and locales (which are wrapped in an environment resource) are cached. This might change in the future, but it’s currently like this.
  • Just like with getContentTypes the SDK can’t really know what kind of results might come from Contentful. Whereas with a single entry or content type you can simply match the ID with what’s stored locally, a call to getEntries might result in any kind of collection, which might also change over time. If you’re querying for all entries with content type blogPost, the results today might differ from yesterday’s results. This is the reason why collection endpoints can never be properly cached. They simply are unpredictable by nature.