<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-AU link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US'>Hi Per,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US'>Thank you for your quick response.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US'>I am currently using ‘vary’ on the deliver coming back from apache – see   <a href="http://pastebin.com/AkwWrs62">http://pastebin.com/AkwWrs62</a>  </span><span style='font-size:11.0pt;font-family:Wingdings;color:#1F497D;mso-fareast-language:EN-US'>ß</span><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US'> called as an include at start of default.vcl <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US'>Looking at the response headers I can see ‘Vary: User-Agent’ set.  Again, varnish is caching all variants but I still cannot purge.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US'>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.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US'>I am still quite new to varnish so I am sorry if this seems like a novice mistake/misunderstanding.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US'>Cheers,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US'>Paul<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif"'> Per Buer [mailto:perbu@varnish-software.com] <br><b>Sent:</b> Friday, 7 March 2014 6:30 PM<br><b>To:</b> Paul McInerney<br><b>Cc:</b> varnish-misc@varnish-cache.org<br><b>Subject:</b> Re: varnish 3.0 + mobile app<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>Hi Paul,<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>On Thu, Mar 6, 2014 at 11:57 PM, Paul McInerney <<a href="mailto:Paul.McInerney@faredge.com.au" target="_blank">Paul.McInerney@faredge.com.au</a>> wrote:<o:p></o:p></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 style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Hi all,<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.0pt;font-family:"Arial","sans-serif";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:"Arial","sans-serif";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><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#222222;background:white'>So I have</span><span style='font-size:10.0pt;font-family:"Arial","sans-serif";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><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#222222;background:white'>required format.</span><span style='font-size:10.0pt;font-family:"Arial","sans-serif";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><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#222222;background:white'>however when I issue a purge against the URL, it purges</span><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#222222'> <span style='background:white'>the cached versions of the </span></span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#222222;background:white'>PC version of the page, and doesn't clear</span><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#222222'> <span style='background:white'>all variants (which should include the mobileapp </span></span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#222222;background:white'>version afaik )</span><o:p></o:p></p></div></div></blockquote><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>It's because you are doing it wrong. There is a very elegant solution to this; HTTP Vary. <o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><a href="https://www.varnish-cache.org/docs/3.0/tutorial/vary.html">https://www.varnish-cache.org/docs/3.0/tutorial/vary.html</a><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></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.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>You can either Vary directly on the custom headers that you are creating or use it on the <span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#500050'>X-UA-Device Javier suggested. I like that.</span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div></div><div><p class=MsoNormal><o:p> </o:p></p></div><p class=MsoNormal>-- <o:p></o:p></p><div><div style='margin-top:3.75pt;margin-right:11.25pt'><table class=MsoNormalTable 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'><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:"Arial","sans-serif";color:#666666'><a href="http://www.varnish-software.com/" target="_blank"><span style='color:#1155CC;text-decoration:none'><img border=0 id="_x0000_i1025" src="http://www.varnish-software.com/static/media/logo-email.png"></span></a><o:p></o:p></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:"Arial","sans-serif";color:#222222'>Per Buer</span></b><span style='font-size:9.0pt;font-family:"Arial","sans-serif";color:#666666'><br>CTO | Varnish Software<br>Phone: +47 958 39 117 | Skype: per.buer<br><b>We Make Websites Fly!<br><br></b></span><b><span style='font-size:10.5pt;font-family:"Arial","sans-serif";color:#666666'>Winner of the Red Herring Top 100 Global Award 2013</span></b><span style='font-size:9.0pt;font-family:"Arial","sans-serif";color:#666666'><o:p></o:p></span></p><p style='margin:0cm;margin-bottom:.0001pt'><span style='font-size:9.0pt;font-family:"Helvetica","sans-serif";color:#666666'><img border=0 id="_x0000_i1026" src="https://www.varnish-software.com/sites/default/files/redherring_2013_winner_sml.jpg"><o:p></o:p></span></p></td></tr></table><p class=MsoNormal><o:p> </o:p></p></div></div></div></div></div></body></html>