<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div name="messageBodySection">
<div dir="auto">Within my vcl_recv, I have something like this:
<div dir="auto"><br /></div>
<div dir="auto"><br /></div>
<div dir="auto">
<div style="color: rgb(204, 204, 204); background-color: rgb(45, 45, 45); font-size: 18px; line-height: 27px; white-space: pre;">
<div><span style="color: #999999;"># Allow purging</span></div>
<div><span style="color: #cc99cc;">if</span> (<span style="color: #f2777a;">req.method</span> == <span style="color: #99cc99;">"PURGE"</span>) {</div>
<div><span style="color: #cc99cc;">if</span> (!<span style="color: #f2777a;">client.ip</span> ~ <span style="color: #6699cc;">purge</span>) {</div>
<div><span style="color: #cc99cc;">return</span> (<span style="color: #f99157;">synth</span>(403, "Forbidden"));</div>
<div>}</div>
<br />
<div><span style="color: #cc99cc;">if</span> (<span style="color: #f2777a;">req.http.xkey-purge</span>) {</div>
<div><span style="color: #cc99cc;">set</span> <span style="color: #f2777a;">req.http.n-gone</span> = xkey.<span style="color: #6699cc;">purge</span>(<span style="color: #f2777a;">req.http.xkey-purge</span>);</div>
<div><span style="color: #999999;"># If you got this stage (and didn't error out above), purge the cached result</span></div>
<div><span style="color: #cc99cc;">return</span> (<span style="color: #f99157;">synth</span>(200, "Invalidated "+req.http.n-gone+" objects"));</div>
<div>} <span style="color: #cc99cc;">else</span> {</div>
<div><span style="color: #cc99cc;">return</span> (<span style="color: #f99157;">purge</span>);</div>
<div>}</div>
<br />
<div>}</div>
</div>
</div>
</div>
</div>
<div name="messageSignatureSection"><br />
<div class="matchFont" dir="auto">…and a a vcl_synth like:</div>
<div class="matchFont" dir="auto"><br /></div>
<div class="matchFont" dir="auto">
<div style="color: rgb(204, 204, 204); background-color: rgb(45, 45, 45); line-height: 27px; white-space: pre;">
<div><span style="color: #cc99cc;">sub</span> vcl_synth {</div>
<div><span style="color: #cc99cc;">if</span> (<span style="color: #f2777a;">resp.status</span> == <span style="color: #f99157;">720</span>) {</div>
<div><span style="color: #999999;"># We use this special error status 720 to force redirects with 301 (permanent) redirects</span></div>
<div><span style="color: #999999;"># To use this, call the following from anywhere in vcl_recv: return (synth(720, "http://host/new.html"));</span></div>
<div><span style="color: #cc99cc;">set</span> <span style="color: #f2777a;">resp.http.Location</span> = <span style="color: #f2777a;">resp.reason</span>;</div>
<div><span style="color: #cc99cc;">set</span> <span style="color: #f2777a;">resp.status</span> = <span style="color: #f99157;">301</span>;</div>
<div><span style="color: #cc99cc;">return</span> (<span style="color: #f99157;">deliver</span>);</div>
<div>} <span style="color: #cc99cc;">elseif</span> (<span style="color: #f2777a;">resp.status</span> == <span style="color: #f99157;">721</span>) {</div>
<div><span style="color: #999999;"># And we use error status 721 to force redirects with a 302 (temporary) redirect</span></div>
<div><span style="color: #999999;"># To use this, call the following from anywhere in vcl_recv: return (synth(720, "http://host/new.html"));</span></div>
<div><span style="color: #cc99cc;">set</span> <span style="color: #f2777a;">resp.http.Location</span> = <span style="color: #f2777a;">resp.reason</span>;</div>
<div><span style="color: #cc99cc;">set</span> <span style="color: #f2777a;">resp.status</span> = <span style="color: #f99157;">302</span>;</div>
<div><span style="color: #cc99cc;">return</span> (<span style="color: #f99157;">deliver</span>);</div>
<div>}</div>
<br />
<div><span style="color: #cc99cc;">return</span> (<span style="color: #f99157;">deliver</span>);</div>
<div>}</div>
</div>
</div>
<div class="matchFont" dir="auto"><br /></div>
<div class="matchFont" dir="auto"><br /></div>
<div class="matchFont" dir="auto">When I perform the xkey-purge request, I get back a 200, and can confirm that the purging is working, but the content-length is always 0 (I don't get the "Invalidated n objects" message).</div>
<div class="matchFont" dir="auto"><br /></div>
<div class="matchFont" dir="auto">Not sure where to start debugging…any idea what could cause this?</div>
<div class="matchFont" dir="auto"><br /></div>
<div class="matchFont">—<br />
Tim Kelty</div>
</div>
</body>
</html>