In Varnish there are some differences between VCL 2.x and 3.0. Hash generation for example. In Varnish 2.x you'd do req.hash += somevar
while in Varnish 3.x you would call hash_data(somevar)
.
Is it possible to write portable Varnish scripts that work on both 2.x and 3.x? Can I if
on the Varnish version for example?
No, it's not possible since Varnish compile vcl configs in C prior to start, so you should translate the config to the right version before or you will get a compile error.