Forum
Varnish with Member app
I have installed varnish on the server and it works great, except on all pages where member signin check is done,
There is a cookie sent from the server (below), this stops varnish from caching that page.
Set-Cookie: PHPSESSID=41q8v6aa3krfvm14et670lm485; expires=Mon, 27-Jun-2016 04:15:30 GMT; Max-Age=432000; path=/; HttpOnly
I am not starting session on the page, however may be perch is already doing it. I have this code near top of the page "perch_member_logged_in()", to see if user is logged in. If user is not logged in, I think it is okay to not pass "set-cookie" or may be there is configuration is varnish I can do to ignore "set-cookie" until someone is logged in.
I want all non-logged in pages to be cached too. Right now I am getting "MISS" in varnish for pages. JPG, JS, CSS seems to be "HIT" for varnish.
The way that PHP handles sessions makes this quite tough. We have to start the session before we can access it to see if the user is authenticated.
So it may just be a fact of life, but I'll take a look and see if there's anything that can be done.
Drew,
You are right about session handling, but I think we can ignore PHPSESSIONID cookie always, until a specific cookie exists.
We can create this cookie when user successfully logs in (creating cookie page can be put in varnish exception, so never gets cached and it would be post request anyway)
Once that cookie exists, varnish will know the user is logged in and honor PHPSESSIONID then onwards.
This is a theory though, haven't been able to fully implement it yet in varnish.