1

I am currently working on a project based on varnish..

we write vcl and vmod. But the project need check the request body. Buddies, How can I get request body in VCL or vmod with a C function? Help Needed.

1

See https://stackoverflow.com/questions/7381220/varnish-vcl-gurus-how-to-pass-request-body-using-varnish-fetch

Varnish does not operate on POST requests, just passes them through.

  • :Hi, andreas, thanks for your reply. Varnish doesnot cache post request, but it matters not much. I need to get the post body in VCL. Do you you know how to realize it? – Shaobo Wang Nov 11 '11 at 8:40
  • I didn't find anything on it. Since varnish doesn't do anything with POSTs except for passing them through, speed is not really of concern here. You could re-route the request to another proxy which CAN work with POSTs, like apache filters or squid. – AndreasM Nov 11 '11 at 13:34
1

TL;DR;

I think this answer is what you need: https://stackoverflow.com/a/12181364/1016425

As mentioned previously by @AndreasM Varnish does not cache POST request by default. But this can be changed if you want.

If you need to cache POST request, this is possible and basically you need to make use of:

bodyaccess.hash_req_body();

This tutorial has a very good step by step explanation: https://docs.varnish-software.com/tutorials/caching-post-requests/

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.