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

Caching problems with JSON-LD Context output #1219

Closed
RichardWallis opened this issue Jun 21, 2016 · 2 comments
Closed

Caching problems with JSON-LD Context output #1219

RichardWallis opened this issue Jun 21, 2016 · 2 comments
Assignees
Labels
site tools + python code Infrastructural issues around schema.org site. Most can ignore this!

Comments

@RichardWallis
Copy link
Contributor

Requests to http://schema.org can either return the html home page or [if an accept type of application/ld+json is passed in the request] it can return the json-ld context file.

With http caching enabled, using etags etc. browsers (Chrome) are not differentiating between the two.

Result is that if a browser has cached the context file, prior to visiting the home page, the user can be presented with JSON-LD output instead of the html home page.

This happens if an in-browser application asks for the context file. Example applications where this can occur include the JSON-LD Playground and the Openlink Structured Data Sniffer extension tool.

Also if the html version of the page has been cached in the browser when applications such as JSON-LD Playground request the context file, they get the html which causes an error reading the context.

Fix required to ensure that json-ld context and html home page are not confused in browser caches.

@RichardWallis RichardWallis added the site tools + python code Infrastructural issues around schema.org site. Most can ignore this! label Jun 21, 2016
@RichardWallis RichardWallis self-assigned this Jun 21, 2016
@danbri
Copy link
Contributor

danbri commented Jun 21, 2016

Steps to reproduce:

    1. empty browser cache (last hour)
    1. show Person example in json-ld playground
    1. in other tab go to http://schema.org - get context file displayed

Related links:

From @lanthaler "It was the vary header as initially suspected. When you respond with JSON-LD, you don't set it. You need to set it in all cases."

curl -H "Accept: application/ld+json" -I http://schema.org/

The relevant code is at https://github.com/schemaorg/schemaorg/blob/sdo-makemake/sdoapp.py#L1064

    if (ENABLE_JSONLD_CONTEXT and (jsonld_score < html_score and jsonld_score < xhtml_score)):
        jsonldcontext = GetJsonLdContext(layers=ALL_LAYERS)
        self.response.headers['Content-Type'] = "application/ld+json"
        #self.emitCacheHeaders()
        self.response.out.write( jsonldcontext )
        return True

RichardWallis pushed a commit that referenced this issue Jun 21, 2016
In-browser caching conflicts between home page and json-ld context
Ensure output of 'vary' header.
Collect outputing of json-ld context in one place and redirect to it from home page.
@RichardWallis
Copy link
Contributor Author

Fixed in 3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
site tools + python code Infrastructural issues around schema.org site. Most can ignore this!
Projects
None yet
Development

No branches or pull requests

2 participants