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

Improve how SLDR downloads langtag.json file #987

Open
jwickberg opened this issue Nov 5, 2020 · 3 comments · May be fixed by #1232
Open

Improve how SLDR downloads langtag.json file #987

jwickberg opened this issue Nov 5, 2020 · 3 comments · May be fixed by #1232
Assignees

Comments

@jwickberg
Copy link
Contributor

When SLDR is initialized, it currently does a synchronous request to download the langtags.json file and this request can be slow on machines with slow internet connections.

It would be better if the download of the langtags.json file could be separated out from the initialization code and allow applications to decide when to make the call.

Also, the SLDR code currently uses the IF-MODIFIED-SINCE header and for a while this was broken on the server. It is working now, but WSTech would like us to switch to using the ETag method instead since this is now more common. They gave this as a reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag

@ermshiperete
Copy link
Member

It would be better if the download of the langtags.json file could be separated out from the initialization code and allow applications to decide when to make the call.

@jwickberg Don't we have that already? There's Sldr.InitializeLanguageTags() which does the download of langtags.json. The application can decide when that gets called. If it has been called before (i.e. if _languageTags is not null) we won't do the download again. Or do you mean that we should always use the local langtags.json file, and do the download in a separate method that the application can call when it pleases to do so?

@jwickberg
Copy link
Contributor Author

@ermshiperete I created this when I found that Paratext was starting slowly on some machines because of the download of the langtags.json file - this was made worse because the IF-MODIFIED-SINCE wasn't working which meant the file was always being downloaded. That was corrected on the server, but WSTech suggested we do the check a different way.
If we are sure that the timestamp check is working - the flag is less important.
Probably need to check with WSTech again to see the best way to make sure that the timestamp works.

@ermshiperete
Copy link
Member

ermshiperete commented Feb 1, 2022

I think what needs to happen:

  1. extract downloading code to a new public method
  2. change signature of Sldr.InitializeLanguageTags() to Sldr.InitializeLanguageTags(bool downloadLangTags = true) and call the new download method only if downloadLangTags is true. This deserves a +semver:major in the commit message (and an entry in CHANGELOG.md).
  3. change download method to use ETag (IF-NONE-MATCH header) instead of IF-MODIFIED-SINCE header. This requires a way to store the ETag of the downloaded file somewhere, maybe in a separate file (langtags.json.etag). Downloading should re-populate _languageTags.

elisunger added a commit to elisunger/libpalaso that referenced this issue Oct 14, 2022
@ermshiperete ermshiperete linked a pull request Oct 14, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants