varnish 3.0 + mobile app

Paul McInerney Paul.McInerney at faredge.com.au
Thu Mar 6 23:57:15 CET 2014


Hi all,

We are currently developing a mobile android/iphone app for our website.

When the app hits the varnish frontend, it has the user-agent string set as 'mobileapp'.
So I have put in place a subroutine that correctly identifies the app and sets a
custom x-device header to send to the backend for rendering the page(s) in the
required format.

This part is working well with the same URL now serving both formats of the page,
however when I issue a purge against the URL, it purges the cached versions of the
PC version of the page, and doesn't clear all variants (which should include the mobileapp
version afaik )

Here's the subroutine called from vlc_recv

sub identify_device {
        unset req.http.X-UA-Device;
        set req.http.X-UA-Device = "pc";

 if (req.http.User-Agent ~ "mobileapp" ) {
        set req.http.X-UA-Device = "mobileapp";
  }
}

and the hash being set based on device

sub vcl_hash {
    if (req.http.X-UA-Device) {
        hash_data(req.http.X-UA-Device);
    }
}

What am I doing wrong? or missing? or not understanding?

Cheers,

:)

--
Paul McInerney
Senior Systems Administrator
Far Edge Technology

P:   +61 2  8425 1410
F:   +61 2  8425 1489
M: +61 411 288 030
E:   paul.mcinerney at faredge.com.au

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20140307/3d6e57ac/attachment.html>


More information about the varnish-misc mailing list