Varnish doesn't cache after Typo3 Backend Logout - be_typo3_user cookie still alive

Viewed 72

I am using typo3-9.5.18 with the varnish-connector extension. Varnish chaches the frontend, and does not cache anything if I am logged in into the backend. The problem is, varnish does not cache again after I log out of the backend. I assume it is because of the cookie 'be_typo3_user', which is still alive after logging out. The problem is similar to Bug #36334 on https://forge.typo3.org/issues/36334 , however this solution is 7 years old. Is there a clever solution to this?

1 Answers

Assuming the logout URL is /logout, you could write some VCL in Varnish to delete the cookie for you.

Here's a VCL snippet that does the job:

sub vcl_backend_response {
    if(bereq.url == "/logout") {
        set beresp.http.set-cookie = "Set-Cookie: be_typo3_user=deleted; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT";
    }
}

You can just add this piece of VCL to your existing VCL file on your Varnish server and modify the matching URL accordingly.

Hope that helps.

Related