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

List:       varnish-misc
Subject:    Docs : Only handle actual PURGE HTTP methods, everything else is discarded
From:       "AWA SOLUTIONS" <contact () awa ! solutions>
Date:       2018-03-30 15:11:35
Message-ID: 001a01d3c839$64cc5480$2e64fd80$ () solutions
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi there,

 

While reading the docs, I found this in
https://www.varnish-software.com/wiki/content/tutorials/varnish/sample_vclTe
mplate.html :

 

HANDLING HTTP PURGE

  sub vcl_purge {

    # Only handle actual PURGE HTTP methods, everything else is discarded

    if (req.method != "PURGE") {

      # restart request

      set req.http.X-Purge = "Yes";

      return(restart);

    }

  }

 

 

But in mattiasgeniar/varnish-4.0-configuration-templates
https://github.com/mattiasgeniar/varnish-4.0-configuration-templates/blob/ma
ster/default.vcl 

This is just the opposite logic :

 

sub vcl_purge {

  # Only handle actual PURGE HTTP methods, everything else is discarded

  if (req.method == "PURGE") {

    # restart request

    set req.http.X-Purge = "Yes";

    return (restart);

  }

}

 

So I assume the latter, wiki page, has a typo ?!

 

Last, in
https://book.varnish-software.com/4.0/chapters/Cache_Invalidation.html ,
after similar vcl_recv conditions than above to return purge, vcl_purge
subroutine sets req.method instead of req.http.X-Purge :

 

sub vcl_purge {

    set req.method = "GET";

    return (restart);

}

 

Sounds logical to change req.method to avoid infinite loops, so why isn't it
the same in above examples ?

 

Thank you !

 

	
		
		
		
		
		
		
		

 


[Attachment #5 (text/html)]

<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 12 \
(filtered medium)"><style><!-- /* Font Definitions */
@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:11.0pt;
	font-family:"Calibri","sans-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;}
span.EmailStyle17
	{mso-style-type:personal;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
span.EmailStyle18
	{mso-style-type:personal-reply;
	font-family:"Calibri","sans-serif";
	color:#1F497D;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-size:10.0pt;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:70.85pt 70.85pt 70.85pt 70.85pt;}
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=FR link=blue vlink=purple><div \
class=WordSection1><p class=MsoNormal>Hi there,<o:p></o:p></p><p \
class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><span lang=EN-US>While \
reading the docs, I found this in <a \
href="https://www.varnish-software.com/wiki/content/tutorials/varnish/sample_vclTempla \
te.html">https://www.varnish-software.com/wiki/content/tutorials/varnish/sample_vclTemplate.html</a> \
:<o:p></o:p></span></p><p class=MsoNormal><span \
lang=EN-US><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><b><span \
lang=EN-US>HANDLING HTTP PURGE<o:p></o:p></span></b></p><p class=MsoNormal><span \
lang=EN-US>&nbsp; sub vcl_purge {<o:p></o:p></span></p><p class=MsoNormal><span \
lang=EN-US>&nbsp;&nbsp;&nbsp; <i># Only handle actual PURGE HTTP methods, everything \
else is discarded</i><o:p></o:p></span></p><p class=MsoNormal><span \
lang=EN-US>&nbsp;&nbsp;&nbsp; <b>if</b> (req.method != &quot;PURGE&quot;) \
{<o:p></o:p></span></p><p class=MsoNormal><span \
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <i># restart \
request</i><o:p></o:p></span></p><p class=MsoNormal><span \
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set req.http.X-Purge = \
&quot;Yes&quot;;<o:p></o:p></span></p><p class=MsoNormal><span \
lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
</span><b>return</b>(restart);<o:p></o:p></p><p class=MsoNormal>&nbsp;&nbsp;&nbsp; \
}<o:p></o:p></p><p class=MsoNormal>&nbsp; }<o:p></o:p></p><p \
class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p \
class=MsoNormal><span lang=EN-US>But in \
mattiasgeniar/varnish-4.0-configuration-templates <a \
href="https://github.com/mattiasgeniar/varnish-4.0-configuration-templates/blob/master \
/default.vcl">https://github.com/mattiasgeniar/varnish-4.0-configuration-templates/blob/master/default.vcl</a> \
<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>This is just the opposite \
logic :<o:p></o:p></span></p><p class=MsoNormal><span \
lang=EN-US><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-US>sub \
vcl_purge {<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>&nbsp; # <i>Only \
handle actual PURGE HTTP methods, everything else is \
discarded</i><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>&nbsp; if \
(req.method == &quot;PURGE&quot;) {<o:p></o:p></span></p><p class=MsoNormal><span \
lang=EN-US>&nbsp;&nbsp;&nbsp; # <i>restart request<o:p></o:p></i></span></p><p \
class=MsoNormal><span lang=EN-US>&nbsp;&nbsp;&nbsp; set req.http.X-Purge = \
&quot;Yes&quot;;<o:p></o:p></span></p><p class=MsoNormal><span \
lang=EN-US>&nbsp;&nbsp;&nbsp; return (restart);<o:p></o:p></span></p><p \
class=MsoNormal><span lang=EN-US>&nbsp; }<o:p></o:p></span></p><p \
class=MsoNormal><span lang=EN-US>}<o:p></o:p></span></p><p class=MsoNormal><span \
lang=EN-US><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-US>So I \
assume the latter, wiki page, has a typo ?!<o:p></o:p></span></p><p \
class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p>&nbsp;</o:p></span></p><p \
class=MsoNormal><span lang=EN-US style='color:#1F497D'>Last, in <a \
href="https://book.varnish-software.com/4.0/chapters/Cache_Invalidation.html">https://book.varnish-software.com/4.0/chapters/Cache_Invalidation.html</a> \
, after similar vcl_recv conditions than above to return purge, vcl_purge subroutine \
sets req.method instead of req.http.X-Purge :<o:p></o:p></span></p><p \
class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p>&nbsp;</o:p></span></p><p \
class=MsoNormal><span lang=EN-US style='color:#1F497D'>sub vcl_purge \
{<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US \
style='color:#1F497D'>&nbsp;&nbsp;&nbsp; set req.method = \
&quot;GET&quot;;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US \
style='color:#1F497D'>&nbsp;&nbsp;&nbsp; return (restart);<o:p></o:p></span></p><p \
class=MsoNormal><span lang=EN-US style='color:#1F497D'>}<o:p></o:p></span></p><p \
class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p>&nbsp;</o:p></span></p><p \
class=MsoNormal><span lang=EN-US style='color:#1F497D'>Sounds logical to change \
req.method to avoid infinite loops, so why isn&#8217;t it the same in above examples \
?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US \
style='color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span \
lang=EN-US>Thank<span style='color:#1F497D'> you !</span><o:p></o:p></span></p><p \
class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p><table \
class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 \
style='background:white;border-collapse:collapse'><tr><td valign=top \
style='padding:0cm 6.0pt 0cm 6.0pt'></td></tr><tr><td width=50 nowrap valign=top \
style='width:29.75pt;padding:0cm 6.0pt 0cm 6.0pt'></td><td valign=top \
style='padding:0cm 6.0pt 0cm 6.0pt'></td></tr><tr><td width=50 nowrap valign=top \
style='width:29.75pt;padding:0cm 6.0pt 0cm 6.0pt'></td><td valign=top \
style='padding:0cm 6.0pt 0cm 6.0pt'></td></tr><tr><td width=50 nowrap valign=top \
style='width:29.75pt;padding:0cm 6.0pt 0cm 6.0pt'></td><td valign=top \
style='padding:0cm 6.0pt 0cm 6.0pt'></td></tr><tr><td width=50 nowrap valign=top \
style='width:29.75pt;padding:0cm 6.0pt 0cm 6.0pt'></td><td valign=top \
style='padding:0cm 6.0pt 0cm 6.0pt'></td></tr><tr><td width=50 nowrap valign=top \
style='width:29.75pt;padding:0cm 6.0pt 0cm 6.0pt'></td><td valign=top \
style='padding:0cm 6.0pt 0cm 6.0pt'></td></tr><tr><td width=50 nowrap valign=top \
style='width:29.75pt;padding:0cm 6.0pt 0cm 6.0pt'></td><td valign=top \
style='padding:0cm 6.0pt 0cm 6.0pt'></td></tr><tr><td width=50 nowrap valign=top \
style='width:29.75pt;padding:0cm 6.0pt 0cm 6.0pt'></td><td valign=top \
style='padding:0cm 6.0pt 0cm 6.0pt'></td></tr></table><p class=MsoNormal><span \
lang=EN-US><o:p>&nbsp;</o:p></span></p></div></body></html>



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

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

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