It is sometimes useful to use the following rule to make decisions in VCL,
based on Content-Length:
vcl_fetch() {
# Cache objects larger than 3000 bytes
if ((beresp.status == 200) && (beresp.http.Content-Length ~
"^([3-9]|\d\d)\d\d\d")) {
set beresp.ttl = 10d;
} else {
set beresp.ttl = 10m;
} }
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.
This is a horrible hack that works fine, until we get some chunked responses
and the above regexp fails.
So I would prefer:
if ((beresp.status == 200) && (length(body) > 3000)) {
# Cache a long time
}
Does this exist without in-line C, is it a valuable feature, etc. so forth?
-T.
_______________________________________________
varnish-dev mailing list
[email protected]
http://lists.varnish-cache.org/mailman/listinfo/varnish-dev