[Varnish] #1741: All request methods are changed to GET on cache miss

Varnish varnish-bugs at varnish-cache.org
Wed May 27 11:39:25 CEST 2015

#1741: All request methods are changed to GET on cache miss
 Reporter:  askalski  |       Owner:
     Type:  defect    |      Status:  new
 Priority:  normal    |   Milestone:
Component:  build     |     Version:  4.0.3
 Severity:  normal    |  Resolution:
 Keywords:            |

Comment (by aondio):

 This is the way it is supposed to work.
 Both the request methods converted to GET on backend side and returning
 "pass" for non-GET/HEAD requests are decisions taken for security reasons.

 For example a POST request can't be cached and can lead to security
 violations on backend side if not convert to GET.

 If you want to cache OPTIONS request, you can either implement some logic
 using the req.method you can do it in your vcl(safe thing to do):

 sub vcl_recv {
     if (req.method == "OPTIONS")

 or you can move this logic to vcl_backend_fetch :
 sub vcl_backend_fetch {
     set bereq.method = "GET";
 Note that the second solutions is not completely safe because doing so we
 force the bereq method and this can lead to undefined territories (as
 written above), some padding logic is required in this situation.

Ticket URL: <https://www.varnish-cache.org/trac/ticket/1741#comment:1>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

More information about the varnish-bugs mailing list