mORMot2
mORMot2 copied to clipboard
Use HTTP server as web proxy with cache
A caching logic, similar to the PeerCache local temporary cache, is to be used.
For a given URI, e.g. https://mormotcache.ad.company.com/*, we redirect to another server
So that e.g.
https://mormotcache.ad.company.com/https/srvorigin.ad.company.com/application/file
will trigger the following process:
- make a HEAD
https://srvorigin.ad.company.com/application/file - compute a hash of its URI + last-modify = HASH (not content-length because it may not be available)
- check for a local file name from this HASH
4a) if the file exists, change its timestamp to the current time, and serve it to the client
4b) if the file does not exist, start downloading from GET
https://srvorigin.ad.company.com, serve it in "progressive" mode (like PeerCache) to the client, then eventually copy the file to the local temporary folder - once in a while, check for deprecated files in the local temporary folder
OnRemoteUri event callback could check for the remote URI validity, with any additional information (e.g. TLS client certificate) for both HEAD and GET.
We can't directly reuse the PeerCache logic for this process, because there is no content hashing, and the actual usecase is not the same.
Most of it is implemented.
What is missing is
- [ ] integrated PeerCache, especially when run on the loopback, for the remote HEAD/GET
https://srvorigin.ad.company.com - [ ] to use
THttpCacheFilesfrom mormot.net.client.pas to store locally the metadata and not touching the file timestamp (which is confusing) - may be also beneficial to the PeerCache local cache (as option in both places?)