arbindo / mimock

Platform to setup mocks for REST endpoints
https://mimock.dev
Apache License 2.0
17 stars 3 forks source link

💻 [API] Enable response caching for mocks #272

Open neel1996 opened 1 year ago

neel1996 commented 1 year ago

Summary

Explore springboot caching to enable it for mock responses. Use the hash generated from the request body + headers as the key for the cache

Scope of the issue

To improve mock response performance

Impacted area

Supporting artifacts

No response

neel1996 commented 1 year ago

Caching & Eviction considerations

Caching

Route + Http method + Query param string + Request headers + Request body

Eviction

E.g:

Let's assume "client-x" invokes a "mock_a" with the following request headers 

- Authorization
- Content-type
- Host

These headers will decide the cache key. However, it is not necessary for the mock stored in the DB to have the same set of headers if strict header matching is not enabled for the mock.

In this case, if the user updates "mock_a", then the eviction will not remove the mock data from the cache as the hashed key will be different. Hence, all the existing cache needs to be evicted to ensure consistency