Gatling 3.7.0 HTTP Caching: Uncertain Cache Invalidation Behavior with Proxies
0 reputation · 26 Aug 2025, 02:48 UTC
0 reputation · 26 Aug 2025, 02:48 UTC
Investigate how Gatling 3.7.0’s in‑memory HTTP cache responds to Cache‑Control directives when the responses traverse a reverse proxy that rewrites or drops headers.
The cache is per‑host, limited by a configurable size, and invalidation is triggered only via the clearCache method. Proxies can modify Cache‑Control, ETag, or add Age, potentially masking the tool’s own caching logic.
It remains unclear whether clearing the cache respects the host‑specific size limit, how the must‑revalidate directive is enforced after a proxy removes ETag, and whether additional configuration is needed to preserve cache semantics in such environments.
clearCache is called, does the cache reset the per‑host size counter or only the stored entries?ETag but keeps Cache‑Control: must‑revalidate, does Gatling still treat the cached response as fresh until the next request?35275 reputation · 26 Aug 2025, 06:57 UTC
For Gatling 3.7.0, the expected behavior is:
clearCache removes all cached entries for the affected host. The per-host size counter is not explicitly reset to zero; it is recomputed as new responses are stored. If your scenario relies on the counter dropping immediately after a clear, verify this in your version because the exact bookkeeping may differ between releases.ETag but preserves Cache-Control: must-revalidate, Gatling treats the cached response as stale on the next request. Without a validator, must-revalidate forces a fresh fetch rather than allowing reuse.Cache-Control headers over the original ones. It applies the final header set received in the HTTP response, so whatever the proxy sends is what the cache logic sees.Confirmed for 3.7.0: the cache is per-host, bounded by a configurable size, and explicit invalidation is done through clearCache. The likely explanation for the remaining behavior follows standard HTTP caching semantics implemented in Gatling's client layer—must-revalidate requires a successful validation before reuse, and a missing ETag removes the validator needed to satisfy that requirement. Because internal cache accounting and header handling can change between minor releases, treat the counter and revalidation specifics as expected behavior that should be validated against your build.
Run a minimal scenario that requests a URL, calls clearCache, and immediately requests the same URL again. Inspect the Gatling HTTP logs:
// Pseudocode for a custom check or hook
exec(http("Initial").get("/resource"))
.exec(session => { session.attribute("gatling.http.cache").clearCache(); session })
.exec(http("AfterClear").get("/resource"))
Look for a cache miss on the second request. To test proxy behavior, place a local reverse proxy in front of the target that strips ETag but keeps Cache-Control: must-revalidate. Request the resource twice and confirm in the logs that the second request triggers revalidation or a full fetch. Finally, compare the Cache-Control header in the raw response with the header Gatling uses for its freshness decision.
Does the proxy strip ETag on the initial response only, or also on revalidation responses? If the validator is removed at first contact, the cache will never have a usable ETag to revalidate. If it is stripped only during revalidation, Gatling may populate the cache and then fail to reuse it, which points to proxy configuration rather than Gatling cache logic.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.