Thanks for fast reply,<br><br>but I pasted wrong, actually when I remove these block, it doesn't work<br><br>Here my configure again:<br><br><div style="margin-left: 40px;"><span style="color: rgb(153, 51, 0);">sub vcl_recv {</span><br style="color: rgb(153, 51, 0);">
<br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> # Host header check.</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> # * Check if we recognize the domain used</span><br style="color: rgb(153, 51, 0);">
<span style="color: rgb(153, 51, 0);"> # * Normalize host headers to limit cache usage</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> # * Rewrite URL for the virtual host monster</span><br style="color: rgb(153, 51, 0);">
<span style="color: rgb(153, 51, 0);"> # Return an error for other requests.</span><br style="color: rgb(153, 51, 0);"><br style="color: rgb(153, 51, 0);"><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> # cache multimedia</span><br style="color: rgb(153, 51, 0);">
<span style="color: rgb(153, 51, 0);"> #if (req.request == "GET" && req.url ~ "\.(jpg|jpeg|gif|ico)$") {</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> # lookup;</span><br style="color: rgb(153, 51, 0);">
<span style="color: rgb(153, 51, 0);"> #} </span><br style="color: rgb(153, 51, 0);"><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> # cache CSS and JS files</span><br style="color: rgb(153, 51, 0);">
<span style="color: rgb(153, 51, 0);"> if (req.request == "GET" && req.url ~ "\.(css|js)$") {</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> lookup;</span><br style="color: rgb(153, 51, 0);">
<span style="color: rgb(153, 51, 0);"> } </span><br style="color: rgb(153, 51, 0);"><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> # do not cache POST requests</span><br style="color: rgb(153, 51, 0);">
<span style="color: rgb(153, 51, 0);"> if (req.request == "POST") {</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> pipe;</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> }</span><br style="color: rgb(153, 51, 0);">
<br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> if (req.request != "GET" && req.request != "HEAD") {</span><br style="color: rgb(153, 51, 0);"><br style="color: rgb(153, 51, 0);">
<span style="color: rgb(153, 51, 0);"> # figure out if you are allowed to purge stuff from cache</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> if (req.request == "PURGE") {</span><br style="color: rgb(153, 51, 0);">
<span style="color: rgb(153, 51, 0);"> if (!client.ip ~ purge) {</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> error 405 "Not allowed.";</span><br style="color: rgb(153, 51, 0);">
<span style="color: rgb(153, 51, 0);"> }</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> lookup;</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> }</span><br style="color: rgb(153, 51, 0);">
<br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> # else just pass it along</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> pipe;</span><br style="color: rgb(153, 51, 0);">
<span style="color: rgb(153, 51, 0);"> }</span><br style="color: rgb(153, 51, 0);"><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> if (req.http.Authenticate || req.http.Authorization) {</span><br style="color: rgb(153, 51, 0);">
<span style="color: rgb(153, 51, 0);"> pass;</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> }</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);">}</span><br style="color: rgb(153, 51, 0);">
<br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);">sub vcl_hit {</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> if (req.request == "PURGE") {</span><br style="color: rgb(153, 51, 0);">
<span style="color: rgb(153, 51, 0);"> set obj.ttl = 0s;</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> error 200 "Purged.";</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> }</span><br style="color: rgb(153, 51, 0);">
<span style="color: rgb(153, 51, 0);">}</span><br style="color: rgb(153, 51, 0);"><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);">sub vcl_miss {</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> if (req.http.If-Modified-Since) {</span><br style="color: rgb(153, 51, 0);">
<span style="color: rgb(153, 51, 0);"> pass;</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> }</span><br style="color: rgb(153, 51, 0);"><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> if (req.request == "PURGE") {</span><br style="color: rgb(153, 51, 0);">
<span style="color: rgb(153, 51, 0);"> error 404 "Not in cache.";</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> }</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);">}</span><br style="color: rgb(153, 51, 0);">
<br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);">sub vcl_fetch {</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> if (beresp.status == 301 || beresp.status == 302)</span><br style="color: rgb(153, 51, 0);">
<span style="color: rgb(153, 51, 0);"> {</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);"> set beresp.http.Location = regsub(beresp.http.Location, "^(\w+://[^/]+):\d+", "\1");</span><br style="color: rgb(153, 51, 0);">
<span style="color: rgb(153, 51, 0);"> }</span><br style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);">}</span><br></div><br><br>Many thanks and regards<br><br><div class="gmail_quote">On Fri, Sep 24, 2010 at 11:35 AM, Michael Alger <span dir="ltr"><<a href="mailto:varnish@mm.quex.org">varnish@mm.quex.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">On Fri, Sep 24, 2010 at 11:21:18AM +0700, Dang Tung wrote:<br>
><br>
> It's not work for me, may be my configurations are wrong, could anyone help<br>
> me please. Here's my configuration:<br>
><br>
</div><div class="im">> sub vcl_fetch {<br>
> if (!beresp.cacheable) {<br>
> return (pass);<br>
> }<br>
> if (beresp.http.Set-Cookie) {<br>
> return (pass);<br>
> }<br>
> return (deliver);<br>
<br>
</div>Here you are returning from vcl_fetch(), so the following code will<br>
never be executed. You should move that return statement to be the<br>
last in the function.<br>
<div class="im"><br>
> if (beresp.status == 301 || beresp.status == 302)<br>
> {<br>
> set beresp.http.Location = regsub(beresp.http.Location, "^(\w+://[^/]+):\d+", "\1");<br>
> }<br>
> }<br>
<br>
</div><div><div></div><div class="h5">_______________________________________________<br>
varnish-misc mailing list<br>
<a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br>
<a href="http://lists.varnish-cache.org/mailman/listinfo/varnish-misc" target="_blank">http://lists.varnish-cache.org/mailman/listinfo/varnish-misc</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Nguyen Dang Tung<br>