How to turn on caching headers
Opened this issue · 2 comments
I see in #6 we now have caching headers.
This is fantastic, but can you tell me how I invoke this. I am not sure where to start to turn this option on.
Am I correct that this would remove the act of pulling the context from the net every time a process is called?
I just wanted to follow up on this.. I am trying to dig through the commit and see how to set the expireTime and/or neverExpires params. I'm not quite sure how to connect to that though.
given
proc := ld.NewJsonLdProcessor()
options := ld.NewJsonLdOptions("")
options.Format = "application/nquads"
Is there a struct or var I can call to set to turn on caching? I'm hitting the schema.org context 10's of thousands of time and I'd like to stop. :)
Thanks!
Doug
just to maintain the thread I have gotten to this point and it looks to be working but it's possibly not the best example. Please excuse the mapping, we had some providers not using correct prefix/context strings.
func JLDProc() (*ld.JsonLdProcessor, *ld.JsonLdOptions) {
proc := ld.NewJsonLdProcessor()
options := ld.NewJsonLdOptions("")
client := &http.Client{}
nl := ld.NewDefaultDocumentLoader(client)
// testing caching
cdl := ld.NewCachingDocumentLoader(nl)
cdl.PreloadWithMapping(map[string]string{"https://schema.org/": "/home/fils/Project418/gleaner/docs/jsonldcontext.json",
"http://schema.org/": "/home/fils/Project418/gleaner/docs/jsonldcontext.json",
"https://schema.org": "/home/fils/Project418/gleaner/docs/jsonldcontext.json",
"http://schema.org": "/home/fils/Project418/gleaner/docs/jsonldcontext.json"})
options.DocumentLoader = cdl
options.Format = "application/nquads"
return proc, options
}