jsdon-ld-context-cache
Caching json-ld context lookups for performance and network access control.
See http://manu.sporny.org/2016/json-ld-context-caching/ for details on why context caches are needed.
Essentially, by caching json-ld URL lookups, the time for applying json-ld normalization is vastly reduced.
The https://github.com/msporny/json-jsonld-basic-perftest shows how this may be applied.
Replace the jsonld node module "documentLoader" function with a cache lookup. Original cache example:
var async = ;var fs = ;var jsonld = ; var ctx = fs;var CONTEXTS = 'http://schema.org/': ctx; jsonld { ifurl in CONTEXTS return ; else throw 'invalid context: ' + url; };
using json-ld-context-cache
jsonld now supports a documentLoader options parameter.
var jsonld = ;var jsonldcache = contextDir: __dirname + '/../contexts' log :loggerinfo ;var options = documentLoader:jsonldcachedocumentLoader; { return { if err logger; else var res = JSON; logger; };} jsonld;