Mailing List Archive

Purge cache for mobile users

Hope this is the right channel for solving the issue. Varnish has been
implemented a year ago, excellent response, working fine. But after
installation of Mobilefrontend several months later the issues were
detected. (mediawiki 1.38.2, varnish 7.1)
Purges after the page updates run and purge desktop entries automatically
as well, but when the same page is accessed from the mobile device, the old
page version before the update is shown, the mobile entry has not been
purged. Mobilefrontend is installed and configured as advised in
mw:Extension:MobileFrontend/Configuring_browser_auto-detection option 2,
same domain.
The only difference between requests for desktop/mobile version is in the
header x-subdomain: no for mobile version (shows during the debug in
varnishlog). But even curl sending this header for purge request did not


wfLoadExtension( 'MobileFrontend' );
$wgMFAutodetectMobileView = true;
$wgMinervaEnableSiteNotice = true;
$wgMFDefaultSkinClass = 'SkinMinerva';
$wgInternalServer = "";
$wgUseCdn = true;
$wgCdnServers = array();
$wgCdnServers[] = "";

According, it had to
be customized, the page is little out-of-date and according to: a
In sub vcl_recv {
if (req.method == "PURGE") {
if ((req.http.X-Forwarded-For == "ip address") ||
(req.http.X-Forwarded-For == "ip address") ||
(req.http.X-Forwarded-For == "ip address")) {
set = "host";
return (hash);
} else {
return (synth(405, "Not allowed"));
unset req.http.x-subdomain; # Requester shouldn't be allowed to
supply arbitrary X-Subdomain header
if (req.http.User-Agent ~
tbank|symbian|teleca|up.browser|webos)") {
set req.http.x-subdomain = "no";
return (hash);

sub vcl_hash {
# Cache the mobile version of pages separately.
# NOTE: x-subdomain header should only have one value (if it
# therefore vcl_recv() should remove user-supplied X-Subdomain
import purge;

sub my_purge {
set req.http.purged = purge.soft(0s,30s);
if (req.http.purged == "0") {
return (synth(404));
else {
return (synth(200));

After the purge if someone does not request the page and it would not be
loaded into cache, after 30 seconds the page should be loaded automatically.

The consequence of the issue is that mobile users do not see up-to-date
versions of the pages, the only workaround is restart varnish.

Thanks for advice pointing to the solution.

Pavel Spacek