asp.net mvc - How to do donut caching with c# mvc and Varnish? -


i added varnish config

sub vcl_fetch {     set beresp.do_esi = true;   } 

}

in mvc application i've childaction

<div>@* should not cached, change returned value in db *@         1 @html.action("gethour", "index", new { id = 5 })     </div>      <div>         2         <esi:include>@* should cached *@             @html.action("gethour", "index", new { id = 5 })         </esi:include>     </div> 

and added request header

request.headers.add("x-esi", "1"); 

but varnish keeps caching entire page.

what miss? i've notice in browser request header x-esi doesn't exist. varnish remove tag <esi:include

the code in action gethour pretty simple, retrieve decimal sql server.

change this:

<esi:include>@* should cached *@         @html.action("gethour", "index", new { id = 5 })     </esi:include> 

for this:

<esi:include src="/index/gethour/5">           </esi:include> 

and add varnish default.vcl:

sub vcl_fetch {    set beresp.do_esi = true;    if(bereq.url ~ "/index/gethour"){     set beresp.ttl = 0s;   } } 

this partially answered @ronald in comments above. had remove [childactiononly] annotation also.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -