Currently we have 3 applications (varnish backends):
- Eshop
- CMS
- Routing - app which returns status code of which backend should be chosen to hit.
The main idea between this is that we have the same domain for Eshop and CMS. And all links are stored in MySQL database. So to decide where should varnish hit we are using some routing app.
If we are hitting routing backend in the vcl_recv we are checking status in vcl_backend_response and switching the backend like that:
sub vcl_backend_response {
if (591 == beresp.status) {
set bereq.backend = eshopDirector.backend();
return (retry);
} elsif (592 == beresp.status || 593 == beresp.status || 594 == beresp.status) {
set bereq.backend = cmsDirector.backend();
return (retry);
}
}
After retry we are not caching results because vcl_recv stage is not hit again to identify if results has to be retrieved from the cache or from the backend itself.
So the question here, is there any way to identify which backend has to be used from vcl_recv stage, to get cached results afterwards? Maybe it's possible to make CURL request from there to get status from the routing app and handle it accordingly?