[ 
https://issues.apache.org/jira/browse/ANY23-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16416321#comment-16416321
 ] 

Peter Ansell commented on ANY23-336:
------------------------------------

In regards to the referenced remote context, 
[http://schema.org,|http://schema.org,/] it explicitly states in its response 
headers that it isn't cacheable "Cache-Control: private", so it will be 
retrieved each time unless you manually cache it using the JSONLD-Java local 
caching.

{code:bash}
$ curl --dump-header headers-schemaorg.txt -H "Accept: application/ld+json" 
http://schema.org/
$ cat headers-schemaorg.txt 
HTTP/1.1 302 Found
Content-Type: text/html; charset=utf-8
Access-Control-Allow-Origin: *
Location: http://schema.org/docs/jsonldcontext.json
Cache-Control: private, max-age=600
Vary: Accept, Accept-Encoding
Set-Cookie: GOOGAPPUID=3-4pre; Path=/
X-Cloud-Trace-Context: 10d5e0f051fa5c745b3316acb2981132
Date: Tue, 27 Mar 2018 22:02:20 GMT
Server: Google Frontend
Content-Length: 0

$ curl --dump-header headers-schemaorg-https.txt -H "Accept: 
application/ld+json" https://schema.org/
$ cat headers-schemaorg-https.txt 
HTTP/1.1 302 Found
Content-Type: text/html; charset=utf-8
Access-Control-Allow-Origin: *
Location: https://schema.org/docs/jsonldcontext.json
Cache-Control: private, max-age=600
Vary: Accept, Accept-Encoding
Set-Cookie: GOOGAPPUID=3-4pre; Path=/
X-Cloud-Trace-Context: 8ca81b0f555276580faa57beda55e8a1
Date: Tue, 27 Mar 2018 22:02:58 GMT
Server: Google Frontend
Content-Length: 0
Alt-Svc: hq=":443"; ma=2592000; quic=51303432; quic=51303431; quic=51303339; 
quic=51303335,quic=":443"; ma=2592000; v="42,41,39,35"
{code}

The steps necessary to cache the context locally with JSONLD-Java are at:

https://github.com/jsonld-java/jsonld-java#loading-contexts-from-classpath

> Parsing json-ld content takes prohibitively long time
> -----------------------------------------------------
>
>                 Key: ANY23-336
>                 URL: https://issues.apache.org/jira/browse/ANY23-336
>             Project: Apache Any23
>          Issue Type: Bug
>          Components: core, extractors
>    Affects Versions: 2.2
>            Reporter: Hans Brende
>            Assignee: Peter Ansell
>            Priority: Critical
>             Fix For: 2.3
>
>         Attachments: Screen Shot 2018-03-27 at 2.52.15 PM.png, Screen Shot 
> 2018-03-27 at 2.54.43 PM.png
>
>
> Using the page [https://www.guthriegreen.com|https://www.guthriegreen.com/] 
> as a benchmark, a page fetch took about 100 ms, while simply *parsing* the 
> json-ld content on that page took a *staggering 27400 ms*. For reference, I'm 
> using Java 8, build 162, on a Macbook Pro (early 2015).
> The bad news is that this is not our fault.
> I've profiled this behavior down to the 
> {{com.github.jsonldjava.utils.JsonUtils.fromURL(URL, CloseableHttpClient)}} 
> function. 94% of the parsing time is spent there. This function is called 
> when trying to load remote json-ld contexts. 
> In order to avoid loading remote contexts repeatedly, this function tries to 
> *cache* them by using a {{CachingHttpClient}} from the httpclient-osgi 
> library.
> Unfortunately, that strategy is *not* working, as I have recorded exactly 
> *zero* cache hits, meaning that *every* retrieval is a cache miss and a 
> remote context is re-fetched via http every single time it's accessed.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to