SiteTree::get_by_link() problem

Silverstripe Version: 3.21


I’m trying to put a Silverstripe website behind a varnish server. I have a controller that given a url path returns its content in json format. I use SiteTree::get_by_link(“page path”) to fetch the page content. For some reason this function returns false when accessed thru the varnish server.

Can someone tell me why this happends?


When I test from here, I get very similar responses to both.

I do notice that your Varnish config is stripping out all the session data, including the locale, etc. but I’m guessing that’s being covered in the URL anyway.

I think you might need to do a bit of debugging with what’s being passed to that method. If you have a look at the code, silverstripe-cms/SiteTree.php at d33e36c032ba1daafcfeec1d0e7b1b6e352a4e8f · silverstripe/silverstripe-cms · GitHub you can see that it’s just looking in the database for a matching URL segment.
How is the URL segment being passed? Could your Varnish proxy be stripping something out of the request? It might be helpful if you can share some relevant code snippets.