@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
45 lines (27 loc) • 1.9 kB
Markdown
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) > [@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
| Class | Description |
| --- | --- |
| [HttpCachingProxy](./http-caching-proxy.httpcachingproxy.md) | The HTTP proxy implementation. |
## Interfaces
| Interface | Description |
| --- | --- |
| [ProxyOptions](./http-caching-proxy.proxyoptions.md) | |