Wikipedia Zero/Accept-Language Aware Redirects

This page exists to follow along on Accept-Language aware redirect software engineering activity for the mobile web experience on Wikipedia.

A patch has been submitted to allow Accept-Language aware redirects for the "webroot" of "mdot" and "zerodot" Wikipedia traffic originating from known zero-rated operator networks (e.g., where Wikipedia Zero header tagging is in force). When we say "webroot" of "mdot" and "zerodot" we mean http://m.wikipedia.org/, https://m.wikipedia.org/, http://zero.wikipedia.org/, and https://zero.wikipedia.org/.

Here's the patch: https://gerrit.wikimedia.org/r/#/c/169210/

If this goes well on the zero-rated experience, we'll examine putting this in place on the non-zero-rated mdot experience for Wikipedia as well. At present, the non-zero-rated mdot Wikipedia experience as a general rule redirects the user to the English en.m.wikipedia.org main page, despite about 47% of users visiting that webroot not having English as their primary language (n.b., the www.wikipedia.org/ global homepage portal is actually more skewed toward English and, furthermore, lists all Wikipedia languages). And even in the zero-rated context, at present a user's Accept-Language isn't taken into account; rather the user is shown a list of top languages from which to select (usually okay, but not ideal) or the user is redirected to a singular language main page (e.g., English or French). The patch tries to remove some of the cumbersome steps for the user.

Here's how the initial patch works:

Partner tech managers and software engineers who modify Zero: namespaced articles on https://zero.wikimedia.org/ need to do the following to enable Accept-Language aware redirects:


 * 1) Set the showZeroPage value to false.
 * 2) Add the language codes that are permitted to be redirected to the main page in that language to the showLangs array. Ensure that X-CS tagging is enforced in the content accelerator configuration as well.
 * 3) The behavior that will result is as follows:

Given the user is accessing Wikipedia When the user visits the "webroot" of "mdot" or "zerodot" And the operator is configured to not show the language landing page And the user's Accept-Language contains a prefix corresponding the "showLangs" configuration entry Then the user is redirected to the main page for the most relevant Accept-Language prefix.

For example, if an operator is configured with "ur" and "en" in its showLangs field, but the showZeroPage value is set to false, and the user's keyboard language is set to Urdu (e.g., inferred from a header of Accept-Language: ur), if the user visits http://m.wikipedia.org/, the user will be redirected to http://ur.m.wikipedia.org/wiki/Main_Page.

If an operator is configured with showZeroPage set to true, if the user's Accept-Language language prefixes contain a language from the showLangs field, now the user will be sent to the language list, localized for that user's language, though, instead of localized for just one language (as always, language names are themselves presented in their appropriate script).

If an operator is configured with showZeroPage set to true, but the user's Accept-Language language prefixes do not contain a language from the showLangs field, the user will be sent to the language selection page localized for the first showZeroPage language. Technically, what actually happens is the user is first sent to http://.m.wikipedia.org/wiki/Special:ZeroRatedMobileAccess, and then that page bounces the user to http://.m.wikipedia.org/wiki/Special:ZeroRatedMobileAccess, which in turn shows the language list.

If an operator is configured with showZeroPage set to false, but the user's Accept-Language prefixes do not contain a language from the showLangs field, the user will be sent to the language selection page localized for the first showZeroPage language. Technically, what actually happens is the user is first sent to http://.m.wikipedia.org/wiki/Special:ZeroRatedMobileAccess (that is, if preferred_lang is zero-rated; otherwise the user is sent immediately to ), and then that page bounces the user to http://.m.wikipedia.org/wiki/Special:ZeroRatedMobileAccess, which in turn sends the user to the main page for the first language in the showLangs list.

See the  method inside of PageRendering.php around the section where   is validated for the behavior when the user visits Special:ZeroRatedMobileAccess without any meaningful parameters on the URL query. It would be trivial to modify this part of the code to send the user to the main page for a given language provided it is zero-rated. However, to avoid a proliferation of unnecessary objects stored at the /wiki/Special:ZeroRatedMobileAccess endpoint (and its localized versions), it would be more efficient to instead send the user to the main page for a given language directly from the stanza above it where  is checked, confining the redirect cache object growth to the webroot alone and also minimizing tougher-to-diagnose redirect bugs should they ever occur.