how can I make varnish to just cache but don't deliver?
Bedis 9
bedis9 at gmail.com
Tue Jul 6 13:45:52 CEST 2010
Why not running your curl script on the loopback of your slave Varnish?
cheers
On Tue, Jul 6, 2010 at 1:35 PM, Pahud <pahudnet at gmail.com> wrote:
> OK I think this is because 'error' is not allowed in vcl_deliver. After
> some google I found this guy had the same problem with me in 2008.
> http://www.mail-archive.com/varnish-dev@projects.linpro.no/msg00372.html
> But this thread ended up with no solution.
> Please help.
> pahud
>
> On Tue, Jul 6, 2010 at 6:23 PM, Pahud <pahudnet at gmail.com> wrote:
>>
>> I tried varnishd (varnish-2.1.2 SVN 4769:4772) on Gentoo Linux today. And
>> the VCL compilation failed:
>> Message from VCC-compiler:
>> Variable 'obj.http.X-Cache-Only' not accessible in method 'vcl_fetch'.
>> At: (input Line 106 Pos 21)
>> set obj.http.X-Cache-Only = "true";
>> --------------------#####################----------
>> Running VCC-compiler failed, exit 1
>> VCL compilation failed
>> I also tried
>> set resp.http.X-Cache-Only = "true";
>> but still failed.
>> :(
>> pahud
>>
>> On Mon, Jul 5, 2010 at 10:49 PM, Pahud <pahudnet at gmail.com> wrote:
>>>
>>> Thanks for your quick reply. I tried your config and varnish started with
>>> no error but if I send http request in this case, varnish will have empty
>>> response. And if I comment off the vcl_deliver it responds as normal. Can
>>> you help me a little bit more? Thanks again.
>>> pahud
>>>
>>>
>>>
>>>
>>>
>>> On Mon, Jul 5, 2010 at 10:11 PM, Kristian Lyngstøl
>>> <kristian at varnish-software.com> wrote:
>>>>
>>>> On Mon, Jul 5, 2010 at 3:17 PM, Pahud <pahudnet at gmail.com> wrote:
>>>> > vcl_deliver(). So I tried this configuration
>>>> > sub vcl_deliver {
>>>> > if (req.http.Cache-Control ~ "just-cache") {
>>>> > error 200 "Cached";
>>>> > return (pass);
>>>>
>>>> return (pass); doesn't work from vcl_deliver, nor is it needed after
>>>> an error-statement.
>>>>
>>>> > }
>>>> > return (deliver);
>>>> > }
>>>> > But no good luck. I guess vcl_deliver just can't get the value of
>>>> > req.http.Cache-Control.
>>>> > Is it still possible to achieve this just with VCL?
>>>>
>>>> Hmm. What you could do is:
>>>>
>>>> In vcl_fetch: if (req.http.Cache-Control ~ "just-cache") { set
>>>> obj.http.X-Cache-Only = "true"; }
>>>> In vcl_deliver:
>>>>
>>>> if (resp.http.X-Cache-Only == "true") {
>>>> if (obj.hits == 0) {
>>>> error 795 "Cached";
>>>> } else {
>>>> remove resp.http.X-Cache-Only;
>>>> }
>>>> }
>>>>
>>>> I used the error code 795 to differentiate from 200, so you can catch
>>>> it in vcl_error and strip most of the content of the error message if
>>>> you want to. You may use whatever error code you want, of course.
>>>>
>>>> (I haven't tested this, but I don't see why it shouldn't work, except
>>>> perhaps syntax typos).
>>>>
>>>> - Kristian
>>>
>>
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> http://lists.varnish-cache.org/mailman/listinfo/varnish-misc
>
More information about the varnish-misc
mailing list