-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
Large numbers of HTTP requests for the same JSON-LD context due to lack of caching #292
Comments
It seems the issue is a lack of caching in ActiveContextBuilder line 244. I see several ways to tackle this issue:
@filip26 Can I get your thoughts, is there a solution you would prefer? |
HTTP cache must be fully handled by provided How to cache parsed and pre-processed context is another thing. In the next major version I would like to see a separate method allowing you to pre-fetch/process a context separatelly. Something like var context = JsonLd.getContent(....);
var expanded = JsonLd.expand(input, context); So you would be able to re-use a context of a set contexts between calls. |
So that takes 1), and 2.3) out of the question. As of the
That is a neat idea. Yet, I do not see how this would address the issue. I would need to know all contexts used throughout the document tree, which is often not the case. I see that you do aim on the high-level API (JsonLd object). As I should be able to use re-use cache by sharing the |
@jakubklimek can we close this issue as a shareable cache has been delivered by @skodapetr ? |
@filip26 I would prefer to close it when the resolution makes its way to a release and we can test it in our tool. But I will understand if you want to close it based on the fact that the corresponding test is passing. We can always raise another issue later. |
@jakubklimek great, it's easier link an issue to PR and close it together, to keep it trackable, instead of waiting on a release and then do the closing manually. It's part of Please feel free to re-open or raise a new issue. |
Describe the bug
When parsing a JSON-LD file (JSON-LD to RDF), already loaded external contexts are not cached. In a situation where there is a hierarchy of external contexts referencing each other, and used multiple times in a file, an HTTP request is made every time such a JSON-LD context is required. This results to a large number of identical HTTP requests, flooding the server hosting the contexts, triggering rate limiting, GOAWAY messages, etc., not to mention performance issues.
To Reproduce
Try transforming inzeraty.json to RDF. It contains 36 job advertisements, reusing other JSON-LD contexts.
Expected behavior
Each required context is loaded only once per transformation. Subsequent usages of that context should use the already available copy.
E.g. the JSON-LD playground works this way and transforms the file immediately with 17 HTTP requests for contexts, some of them also duplicate.
Additional context
Originally, the server hosting the contexts, running
nginx
, had the defaultkeepalive_requests 1000;
, which resulted in GOAWAY in approx. 13 seconds of loading the file. I have raised the limit to 10000, which resulted in GOAWAY in 5 minutes. Only after I raised it to 100000, in 13 minutes, the file got processed.The text was updated successfully, but these errors were encountered: