varnish 3.0 + mobile app

Paul McInerney Paul.McInerney at
Fri Mar 7 00:50:56 CET 2014

I thought that myself, and have tried purging with the specific header being called - still no luck.

Doesn't a purge by default, remove all variants of the specified URL?


From: Jennings, Raymond [mailto:raymond.jennings at]
Sent: Friday, 7 March 2014 10:06 AM
To: Paul McInerney
Cc: varnish-misc at
Subject: Re: varnish 3.0 + mobile app

I assume your purge is not hashing properly.  When you purge it has to match whatever it hashed on when the obj went into the cache.

I have problems using the standard sub vcl_hash so I hash only on the URL and not the hostname so this let's me purge from outside of the "restricted area."

In your case I think you probably need to purge all possibilities based on that X-header you are setting.

If that gets too difficult I fallback on doing a BAN instead.


On Thu, Mar 6, 2014 at 5:57 PM, Paul McInerney <Paul.McInerney at<mailto:Paul.McInerney at>> wrote:
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) {

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



Paul McInerney
Senior Systems Administrator
Far Edge Technology

P:   +61 2  8425 1410<tel:%2B61%202%C2%A0%208425%201410>
F:   +61 2  8425 1489<tel:%2B61%202%C2%A0%208425%201489>
M: +61 411 288 030<tel:%2B61%20411%20288%20030>
E:   paul.mcinerney at<mailto:paul.mcinerney at>

varnish-misc mailing list
varnish-misc at<mailto:varnish-misc at>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the varnish-misc mailing list