gradientedge/commercetools-utils

Add simple GET based caching option

jimmythomson opened this issue · 0 comments

The response to GET requests for products, product projections, categories, product types, stores etc. should all be safely cacheable. Other GET requests such as when getting the cart, or the customer's profile, should never be cached.

We should look at implementing a basic cache allowing the user to opt in to caching various resource types through configuration options. Suggest to use node-cache as the caching engine.

There's 2 key pieces of analysis here:

  1. Identify the resources which can reasonably be cached
  2. Determine a clear and flexible way of configuring the caching options

Note: only GET requests can be cached, and should always be keyed on the auth token and all query params, so as to ensure that customer data is never leaked to another customer.