varnish 3.0 + mobile app

Paul McInerney Paul.McInerney at faredge.com.au
Thu Mar 13 15:19:26 CET 2014


Hi Per,

Yes I have purge already working with varnish. I can purge all other variants of the url (as well as other objects for other sites).

It's just with this particular site,  and more specifically for the same url which is rendered differently based on the user-agent string.

So I can purge:

www.site.com or www.site.com/node etc...

but the url www.site.com/?mode=test  (which is displayed differently depending on agent)  I cannot clear from cache. This is what I am trying to hash to as to be able to clear the mobile app version of that url or the pc version,  or both.

Hope that majes sense.

:)


Paul McInerney


-------- Original message --------
From: Per Buer <perbu at varnish-software.com>
Date:
To: Paul McInerney <Paul.McInerney at faredge.com.au>
Cc: varnish-misc at varnish-cache.org
Subject: Re: varnish 3.0 + mobile app


Hi Paul.

Have you set up your VCL to handle PURGE requests as described in the documentation? There is no PURGE support in the VCL you posted.

PURGE is not available our of the box. You need to add it through VCL.


On Thu, Mar 13, 2014 at 1:25 AM, Paul McInerney <Paul.McInerney at faredge.com.au<mailto:Paul.McInerney at faredge.com.au>> wrote:
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<http://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<mailto:perbu at varnish-software.com>]
Sent: Friday, 7 March 2014 6:30 PM

To: Paul McInerney
Cc: varnish-misc at varnish-cache.org<mailto: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<tel:%2B47%20958%2039%20117> | 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]





--
[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/20140314/5b2e327b/attachment-0001.html>


More information about the varnish-misc mailing list