Reputation: 1237
I have a website where the URLs contain the locale information and the client's header Accept-Language (or a select box on each page) chooses the language and redirects to the localized URL for the current page. The default English URL is:
http://example.com/
locale specific versions of the site's pages contain the locale value:
http://example.com/de/
or http://example.com/es/
etc.
I'd like advice on how to handle specifying offline application cache manifests in this situation. I would like localized versions of offline pages to be cached based on the user's URL. i.e. a user landing on the English page and then selecting Spanish would (re?) download the Spanish language URLs specified in the Spanish manifest.
Should I name the manifest file differently for the root page for each locale (e.g. en.manifest, es.manifest)? Or if I use the same named manifest on the root URL for each locale will it be re-read if the user changes to a page with a different locale (and a likely different sized manifest file - the webserver would specify not caching the manifest file(s))? Or do I have to explicitly load the locale specific manifest via JavaScript if the user changes locales?
I'm concerned that a visitor would start the download of the URLs specified in the default English manifest and then choose their preferred locale and not trigger reading the new locale specific manifest and not loading URLs for the selected locale's manifest.
I've done some searching but haven't come across any discussions of this situation.
Upvotes: 0
Views: 294
Reputation: 75707
I'm not sure that this has been around long enough for there to be a widely agreed best practice, but I'll attempt to answer your questions.
i.e. a user landing on the English page and then selecting Spanish would (re?) download the Spanish language URLs specified in the Spanish manifest.
I believe, but can't currently confirm, that if you have files listed in both (say) the en.manifest and the es.manifest then only one copy of that file will be retained in the browser. So include all the shared files in each manifest, that way you don't have to worry about people hitting the home page first in order to get two manifests downloaded. As long as all your static content has far future expires headers the browser should populate the appcache with things from its local cache rather than fetching them again.
Should I name the manifest file differently for the root page for each locale (e.g. en.manifest, es.manifest)?
If there's lots of different languages there's no point making every visitor download every language specific file. So in that scenario you would want to have separate manifests for each language to have more fine grained control over what each user downloads.
Or if I use the same named manifest on the root URL for each locale will it be re-read if the user changes to a page with a different locale (and a likely different sized manifest file - the webserver would specify not caching the manifest file(s))?
The manifest will be re-read whenever it's been updated. This will cause the entire cache to be thrown away and re-downloaded. There's no getting around this, the best approach is not to update the manifest files very often.
Or do I have to explicitly load the locale specific manifest via JavaScript if the user changes locales?
As far as I'm aware you can't download a different manifest file with JavaScript, only the one associated with the page you're currently on by the manifest
attribute.
Upvotes: 1