http-stale-cache-proxy
http-stale-cache-proxy copied to clipboard
What is the purpose of predefining a target?
I do not understand what is the purpose of predefining a target in the configuration.
var httpStaleCacheProxy = require('http-stale-cache-proxy');
httpStaleCacheProxy.createServer({
changeOrigin: true,
target: {
host: 'example.com',
port: 80,
},
}).listen(8000);
Maybe this isn't the library that I am looking for... Here is what I am trying to do:
- I have a service that makes requests to arbitrary URLs (lets call it scrapper).
- I want to proxy the requests that scrapper is making and selectively return a cached version.
In my mind, thats...
- a proxy server thats listening on an arbitrary port (e.g. 9000)
- scrapper makes HTTP request using the said proxy
- proxy intercepts the HTTP request, looks up if the cache exists and if whatever rules indicate that cache should be used, then either returns cached response or proceeds to make the original HTTP request and caches the response.
Is that not what a HTTP proxy is?