jsonld.js icon indicating copy to clipboard operation
jsonld.js copied to clipboard

Implement fetch document loader to supercede xhr one

Open dlongley opened this issue 6 years ago • 4 comments

dlongley avatar Sep 28 '17 18:09 dlongley

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 avatar Nov 06 '17 16:11 pietercolpaert

@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?

mattcollier avatar Nov 06 '17 17:11 mattcollier

It does! I did not know this was possible. Thanks @mattcollier!

pietercolpaert avatar Nov 07 '17 10:11 pietercolpaert

We should consider building this on top of r2.

dlongley avatar Feb 12 '18 05:02 dlongley