varnish 3.0 + mobile app

Paul McInerney Paul.McInerney at faredge.com.au
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   http://pastebin.com/AkwWrs62  <-- 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 'www.site.com/?mode=test'  `, 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.

Cheers,

Paul

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

Hi Paul,


On Thu, Mar 6, 2014 at 11:57 PM, Paul McInerney <Paul.McInerney at faredge.com.au<mailto: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/static/media/logo-email.png]<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

[https://www.varnish-software.com/sites/default/files/redherring_2013_winner_sml.jpg]


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


More information about the varnish-misc mailing list