varnish 3.0 + mobile app

Per Buer perbu at varnish-software.com
Fri Mar 7 08:30:05 CET 2014


Hi Paul,


On Thu, Mar 6, 2014 at 11:57 PM, Paul McInerney <
Paul.McInerney at faredge.com.au> 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.

https://www.varnish-cache.org/docs/3.0/tutorial/vary.html

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.



-- 
 <http://www.varnish-software.com/> *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: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20140307/1dd681bc/attachment.html>


More information about the varnish-misc mailing list