[prev in list] [next in list] [prev in thread] [next in thread] 

List:       varnish-misc
Subject:    Re: varnish 3.0 + mobile app
From:       Paul McInerney <Paul.McInerney () faredge ! com ! au>
Date:       2014-03-13 14:19:26
Message-ID: 7ayw7isqjdvgbearji5311pt.1394720355091 () email ! android ! com
[Download RAW message or body]

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@varnish-software.com>
Date:
To: Paul McInerney <Paul.McInerney@faredge.com.au>
Cc: varnish-misc@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@faredge.com.au<mailto:Paul.McInerney@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@varnish-software.com<mailto:perbu@varnish-software.com>]
Sent: Friday, 7 March 2014 6:30 PM

To: Paul McInerney
Cc: varnish-misc@varnish-cache.org<mailto:varnish-misc@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@faredge.com.au<mailto:Paul.McInerney@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]


[Attachment #3 (text/html)]

<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body>
<div>Hi Per,</div>
<div><br>
</div>
<div>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).</div> <div><br>
</div>
<div>It's just with this particular site, &nbsp;and more specifically for the same \
url which is rendered differently based on the user-agent string.</div> <div><br>
</div>
<div>So I can purge:</div>
<div><br>
</div>
<div>www.site.com or www.site.com/node etc...&nbsp;</div>
<div><br>
</div>
<div>but the url www.site.com/?mode=test &nbsp;(which is displayed differently \
depending on agent) &nbsp;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, \
&nbsp;or both.</div> <div><br>
</div>
<div>Hope that majes sense.</div>
<div><br>
</div>
<div>:)</div>
<div><br>
</div>
<div><br>
</div>
Paul McInerney<br>
<br>
<br>
-------- Original message --------<br>
From: Per Buer &lt;perbu@varnish-software.com&gt; <br>
Date: <br>
To: Paul McInerney &lt;Paul.McInerney@faredge.com.au&gt; <br>
Cc: varnish-misc@varnish-cache.org <br>
Subject: Re: varnish 3.0 &#43; mobile app <br>
<br>
<br>
<div>
<div dir="ltr">Hi Paul.
<div><br>
</div>
<div>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.</div> <div><br>
</div>
<div>PURGE is not available our of the box. You need to add it through VCL.</div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Thu, Mar 13, 2014 at 1:25 AM, Paul McInerney <span \
dir="ltr"> &lt;<a href="mailto:Paul.McInerney@faredge.com.au" \
target="_blank">Paul.McInerney@faredge.com.au</a>&gt;</span> wrote:<br> <blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> <div lang="EN-AU" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Hi \
Per,<u></u><u></u></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Thank \
you for your quick response.<u></u><u></u></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">I \
am currently using ‘vary’ on the deliver coming back from apache – see &nbsp;&nbsp;<a \
href="http://pastebin.com/AkwWrs62" \
target="_blank">http://pastebin.com/AkwWrs62</a>&nbsp; </span><span \
style="font-size:11.0pt;font-family:Wingdings;color:#1f497d">ß</span><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> \
called as an include at start of default.vcl <u></u><u></u></span></p>
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Looking \
at the response headers I can see ‘Vary: User-Agent’ set. &nbsp;Again, varnish is \
caching all variants but I still cannot purge.<u></u><u></u></span></p> <p \
class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">If \
I just execute &nbsp;` curl -I -X PURGE ‘<a href="http://www.site.com/?mode=test" \
target="_blank">www.site.com/?mode=test</a>’&nbsp; `, it returns a MISS when all  \
variants of that URL are being cached.<u></u><u></u></span></p> <p \
class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">I \
am still quite new to varnish so I am sorry if this seems like a novice \
mistake/misunderstanding.<u></u><u></u></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Cheers,<u></u><u></u></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Paul<u></u><u></u></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>&nbsp;<u></u></span></p>
 <p class="MsoNormal"><b><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;">From:</span></b><span \
lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;"> \
Per Buer [mailto:<a href="mailto:perbu@varnish-software.com" \
target="_blank">perbu@varnish-software.com</a>] <br>
<b>Sent:</b> Friday, 7 March 2014 6:30 PM</span></p>
<div class=""><br>
<b>To:</b> Paul McInerney<br>
<b>Cc:</b> <a href="mailto:varnish-misc@varnish-cache.org" \
target="_blank">varnish-misc@varnish-cache.org</a><br> <b>Subject:</b> Re: varnish \
3.0 &#43; mobile app<u></u><u></u></div> <p></p>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
<div>
<p class="MsoNormal">Hi Paul,<u></u><u></u></p>
<div>
<div class="h5">
<div>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
<div>
<p class="MsoNormal">On Thu, Mar 6, 2014 at 11:57 PM, Paul McInerney &lt;<a \
href="mailto:Paul.McInerney@faredge.com.au" \
target="_blank">Paul.McInerney@faredge.com.au</a>&gt; wrote:<u></u><u></u></p> \
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm \
6.0pt;margin-left:4.8pt;margin-right:0cm"> <div>
<div>
<p class="MsoNormal">Hi all,<u></u><u></u></p>
<p class="MsoNormal">&nbsp;<u></u><u></u></p>
<p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#222222;background:white">We \
are currently developing a mobile android/iphone app for our website.</span><span \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#222222"><br>
 <br>
<span style="background:white">When the app hits the varnish frontend, it has the \
user-agent string set as 'mobileapp'. </span></span><u></u><u></u></p>
<p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#222222;background:white">So \
I have</span><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#222222">
 <span style="background:white">put in place a subroutine that correctly identifies \
the app and sets a</span><br> <span style="background:white">custom x-device header \
to send to the backend for rendering the</span> <span \
style="background:white">page(s) in the</span></span><u></u><u></u></p> <p \
class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#222222;background:white">required \
format.</span><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#222222"><br>
 <br>
<span style="background:white">This part is working well with the same URL now \
serving both formats</span> <span style="background:white">of the page, \
</span></span><u></u><u></u></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#222222;background:white">however \
when I issue a purge against the URL, it purges</span><span \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#222222">
 <span style="background:white">the cached versions of the \
</span></span><u></u><u></u></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#222222;background:white">PC \
version of the page, and doesn't clear</span><span \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#222222">
 <span style="background:white">all variants (which should include the mobileapp \
</span> </span><u></u><u></u></p>
<p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#222222;background:white">version \
afaik )</span><u></u><u></u></p> </div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
</div>
<div>
<p class="MsoNormal">It's because you are doing it wrong. There is a very elegant \
solution to this; HTTP Vary.&nbsp;<u></u><u></u></p> </div>
<div>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
</div>
<div>
<p class="MsoNormal"><a \
href="https://www.varnish-cache.org/docs/3.0/tutorial/vary.html" \
target="_blank">https://www.varnish-cache.org/docs/3.0/tutorial/vary.html</a><u></u><u></u></p>
 </div>
<div>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
</div>
<div>
<p class="MsoNormal">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.<u></u><u></u></p> </div>
<div>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
</div>
<div>
<p class="MsoNormal">You can either Vary directly on the custom headers that you are \
creating or use it on the&nbsp;<span \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#500050">X-UA-Device \
Javier suggested. I like that.</span><u></u><u></u></p> </div>
<div>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
</div>
<div>
<p class="MsoNormal">&nbsp;<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
</div>
<p class="MsoNormal">-- <u></u><u></u></p>
<div>
<div style="margin-top:3.75pt;margin-right:11.25pt">
<table border="1" cellspacing="0" cellpadding="0" width="550" \
style="width:412.5pt;border-top:solid #eeeeee \
1.0pt;border-left:none;border-bottom:solid #eeeeee \
1.0pt;border-right:none;text-align:start"> <tbody>
<tr>
<td width="100" style="width:75.0pt;border:none;padding:3.75pt 0cm 3.75pt 0cm">
<p class="MsoNormal" style="line-height:18.0pt"><span \
style="font-size:9.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#666666"><a \
href="http://www.varnish-software.com/" target="_blank"><span \
style="color:#1155cc;text-decoration:none"><img border="0" \
src="http://www.varnish-software.com/static/media/logo-email.png"></span></a><u></u><u></u></span></p>
 </td>
<td style="border:none;padding:3.75pt 0cm 3.75pt 0cm">
<p class="MsoNormal" style="line-height:18.0pt"><b><span \
style="font-size:10.5pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#222222">Per \
Buer</span></b><span \
style="font-size:9.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#666666"><br>
 CTO | Varnish Software<br>
Phone:&nbsp;<a href="tel:%2B47%20958%2039%20117" value="&#43;4795839117" \
target="_blank">&#43;47 958 39 117</a> | Skype: per.buer<br> <b>We Make Websites \
Fly!<br> <br>
</b></span><b><span style="font-size:10.5pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#666666">Winner \
of the Red Herring Top 100 Global Award 2013</span></b><span \
style="font-size:9.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#666666"><u></u><u></u></span></p>
 <p style="margin:0cm;margin-bottom:.0001pt"><span \
style="font-size:9.0pt;font-family:&quot;Helvetica&quot;,&quot;sans-serif&quot;;color:#666666"><img \
border="0" src="https://www.varnish-software.com/sites/default/files/redherring_2013_winner_sml.jpg"><u></u><u></u></span></p>
 </td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><u></u>&nbsp;<u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr">
<div style="font-size:12.727272033691406px;margin:5px 15px 0px \
0px;padding-bottom:5px;color:rgb(34,34,34);font-family:arial,sans-serif;background-color:rgb(255,255,255)">
 <table border="0" cellpadding="0" cellspacing="0" \
style="text-align:start;font-size:12px;line-height:1.5em;font-family:'Helvetica \
Neue',Arial,sans-serif;color:rgb(102,102,102);width:550px;border-top-width:1px;border- \
top-style:solid;border-top-color:rgb(238,238,238);border-bottom-width:1px;border-botto \
m-style:solid;border-bottom-color:rgb(238,238,238);margin-top:20px;padding-top:5px;padding-bottom:5px">
 <tbody>
<tr>
<td width="100" style="font-family:arial,sans-serif;margin:0px"><a \
href="http://www.varnish-software.com/" style="color:rgb(17,85,204)" \
target="_blank"><img \
src="http://www.varnish-software.com/static/media/logo-email.png" \
style="float:left;margin-left:10px"></a></td> <td \
style="font-family:arial,sans-serif;margin:0px"><b \
style="font-size:14px;color:rgb(34,34,34)">Per Buer</b><br> CTO | Varnish \
Software<br> Phone:&nbsp;&#43;47 958 39 117 | Skype: per.buer<br>
<span style="font-weight:bold">We Make Websites Fly!<br>
<br>
</span><span style="font-family:'Helvetica \
Neue',Arial,sans-serif;font-size:14px;font-weight:bold">Winner of the Red Herring Top \
100 Global Award 2013<br> </span>
<p style="margin:0px;line-height:normal;font-family:Helvetica"><img \
src="https://www.varnish-software.com/sites/default/files/redherring_2013_winner_sml.jpg"></p>
 <span style="font-weight:bold"><br>
</span></td>
</tr>
</tbody>
</table>
<div></div>
</div>
<div style="font-size:12.727272033691406px;margin:15px \
0px;clear:both;color:rgb(34,34,34);font-family:arial,sans-serif;background-color:rgb(255,255,255)">
 </div>
</div>
</div>
</div>
</body>
</html>



_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
--===============1414988965343065799==--


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic