It is sometimes useful to use the following rule to make decisions in VCL, based on Content-Length:<br><br>vcl_fetch() {<br> # Cache objects larger than 3000 bytes
<br> if ((beresp.status == 200) && (beresp.http.Content-Length ~ "^([3-9]|\d\d)\d\d\d")) {<br> set beresp.ttl = 10d;<br>} else {<br> set beresp.ttl = 10m;<br>}
}<br><br>The use case is an XML feed that we heuristically know is "well formed" if it's more then 3K; if the response is shorter, it often means the result set was empty for whatever reason (even if it's an HTTP-200 response), so we cache the short requests for a small time until the full result is ready and then cache it for a long time.<br>
<br>This is a horrible hack that works fine, until we get some chunked responses and the above regexp fails.<br><br>So I would prefer:<br><br>if ((beresp.status == 200) && (length(body) > 3000)) {<br> # Cache a long time<br>
}<br><br>Does this exist without in-line C, is it a valuable feature, etc. so forth?<br><br>-T.<br>