UNPKG

@loopback/docs

Version:

Documentation files rendered at [https://loopback.io](https://loopback.io)

83 lines (42 loc) 2.16 kB
--- lang: en title: 'API docs: http-caching-proxy' keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI sidebar: lb4_sidebar editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/http-caching-proxy permalink: /doc/en/lb4/apidocs.http-caching-proxy.html --- <!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@loopback/http-caching-proxy](./http-caching-proxy.md) ## http-caching-proxy package A caching HTTP proxy for integration tests. ## Remarks \*\*NOT SUITABLE FOR PRODUCTION USE!\*\* Testing applications connecting to backend REST/SOAP services can be difficult: The backend service may be slow, apply rate limiting, etc. Integration tests become too slow in such case, which makes test-first development impractical. This can be addressed by setting up a snapshot-based mock server or using a caching HTTP client, but both of these solutions come with severe disadvantages: - When using a snapshot-based mock server, we must ensure that snapshots are up-to-date with the actual backend implementation. - Caching at HTTP-client side requires non-trivial changes of the application code. A filesystem-backed caching HTTP proxy offers a neat solution that combines caching and snapshots: - The first request is forwarded to the actual backend and the response is stored as a snapshot. - Subsequent requests are served by the proxy using the cached snaphost. - Snapshot older than a configured time are discarded and the first next request will fetch the real response from the backend. ## Classes <table><thead><tr><th> Class </th><th> Description </th></tr></thead> <tbody><tr><td markdown="1"> [HttpCachingProxy](./http-caching-proxy.httpcachingproxy.md) </td><td markdown="1"> The HTTP proxy implementation. </td></tr> </tbody></table> ## Interfaces <table><thead><tr><th> Interface </th><th> Description </th></tr></thead> <tbody><tr><td markdown="1"> [ProxyOptions](./http-caching-proxy.proxyoptions.md) </td><td markdown="1"> </td></tr> </tbody></table>