varnish 3.0 + mobile app

Paul McInerney Paul.McInerney at
Thu Mar 13 01:25:03 CET 2014

Hi Per,

Thank you for your quick response.

I am currently using 'vary' on the deliver coming back from apache - see  <-- called as an include at start of default.vcl

Looking at the response headers I can see 'Vary: User-Agent' set.  Again, varnish is caching all variants but I still cannot purge.

If I just execute  ` curl -I -X PURGE ''  `, it returns a MISS when all variants of that URL are being cached.

I am still quite new to varnish so I am sorry if this seems like a novice mistake/misunderstanding.



From: Per Buer [mailto:perbu at]
Sent: Friday, 7 March 2014 6:30 PM
To: Paul McInerney
Cc: varnish-misc at
Subject: Re: varnish 3.0 + mobile app

Hi Paul,

On Thu, Mar 6, 2014 at 11: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 )

It's because you are doing it wrong. There is a very elegant solution to this; HTTP Vary.

You are trying to manipulate the hash, but it fails as you most likely forget to do the same manipulations when purging. This would not be a problem if you where to use Vary as all the variants would be connected to the same hash value.

You can either Vary directly on the custom headers that you are creating or use it on the X-UA-Device Javier suggested. I like that.


Per Buer
CTO | Varnish Software
Phone: +47 958 39 117 | Skype: per.buer
We Make Websites Fly!

Winner of the Red Herring Top 100 Global Award 2013


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

More information about the varnish-misc mailing list