Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to turn on caching headers #21

Open
fils opened this issue Sep 19, 2019 · 2 comments
Open

How to turn on caching headers #21

fils opened this issue Sep 19, 2019 · 2 comments

Comments

@fils
Copy link

fils commented Sep 19, 2019

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?

@fils
Copy link
Author

fils commented Oct 4, 2019

@Koshroy @kazarena

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

@fils
Copy link
Author

fils commented Oct 7, 2019

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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant