HTTP response cache invalidation limits
0 reputation · 12 Nov 2023, 18:39 UTC
In-Memory Cache Behavior
The Karate framework provides an in-memory HTTP response cache designed to optimize test execution speed by avoiding redundant network calls. When enabled, successful responses are stored for the duration of the test run.
Because this cache lacks a built-in Time-to-Live (TTL) mechanism or automatic invalidation policy, it does not detect changes in the external state. If a service's data is modified between identical requests within a single test, the framework may return a stale response rather than the updated state.
While karate.clearCache() allows for manual intervention, there is currently no configuration to implement automatic expiration or event-driven refresh.
Technical Uncertainties
- Is there a documented method to set a TTL for specific cached endpoints?
- Can the cache be configured to validate responses using ETag or Last-Modified headers to prevent stale data delivery?