RESTful API PHP 302 response

kokoniimasu kokoniimasu at gmail.com
Thu Aug 30 02:33:17 CEST 2012


Hi, Mark.

sub vcl_fetch{
  if(beresp.status == 302 && !beresp.http.Location){
    set beresp.status = 200;
    set beresp.response = "OK";
  }
}

This sample is updating for response status at VCL.
But, I think better to look at your php code....


Hope this helps,
--
Syohei Tanaka(@xcir)
http://xcir.net/

(:3[__])

2012/8/30 Mark Strickland <smsmail at roadrunner.com>:
> I have a RESTful API on my website that uses the Tonic.php frame work to
> create the API.  I am running Apache2 and Varnish.  The web site and the API
> works great, but the API returns a code 302 along with the data.  It is
> causing the client apps to have trouble getting the data from the API.  Is
> there any way to get a 200 response sent back?  I though the below would
> stop the 302 response, but it is not.  If you need more information or want
> to try the API let me know and I will send you the information.
>
>
>
> # Do not cache these paths.
>
>   if (req.url ~ "^/status\.php$" ||
>
>       req.url ~ "^/update\.php$" ||
>
>       req.url ~ "^/admin$" ||
>
>       req.url ~ "^/admin/.*$" ||
>
>       req.url ~ "^/flag/.*$" ||
>
>       req.url ~ "^/munin/.*$" ||
>
>       req.url ~ "^.*/ajax/.*$" ||
>
>       req.url ~ "^.*/api/.*$" ||
>
>       req.url ~ "^.*/apidev/.*$" ||
>
>       req.url ~ "^.*/phpmyadmin/.*$" ||
>
>       req.url ~ "^.*/ahah/.*$") {
>
>        return (pass);
>
>   }
>
>
>
>
>
> Here is the headers I am getting back.
>
>
>
> HTTP/1.1 302 Found
>
> X-Varnish-Cache:
>
> MISS
>
> X-Varnish:
>
> 1548785385
>
> Age:
>
> 0
>
> Date:
>
> Wed, 29 Aug 2012 23:37:34 GMT
>
> Content-Length:
>
> 27173
>
> Allow:
>
> PUT, GET
>
> X-Resource:
>
> TaskHandler
>
> Via:
>
> 1.1 varnish
>
> Content-Type:
>
> application/json
>
> Connection:
>
> close
>
> X-Powered-By:
>
> PHP/5.3.2-1ubuntu4.17
>
> Server:
>
> Apache/2.2.14 (Ubuntu)
>
>
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc



More information about the varnish-misc mailing list