jsonld.js
jsonld.js copied to clipboard
Implement fetch document loader to supercede xhr one
Could we also have a way to add our own HTTP and HTTPS protocol implementations? This way, we can plug in our main NodeJS application’s HTTP cache.
@pietercolpaert I'm not sure I understand your proposed use case, but jsonld
allows one to override/extend the built in document loader in any way you like, here is one way that we cache context documents: https://github.com/digitalbazaar/bedrock/blob/master/lib/jsonld.js#L20
Leveraging that functionality, we then build application specific maps of context documents as here: https://github.com/digitalbazaar/bedrock-ledger-context/blob/master/lib/index.js
So, your custom document loader may retrieve documents from any cache you like. Does that address your needs?
It does! I did not know this was possible. Thanks @mattcollier!
We should consider building this on top of r2.