This would be a perfect solution for me as I need to serve some generated content to web browsers. My plan is to generate the content on demand and store it for next time. I don't want the browsers to call my service (which generates the content) every time. I want them to go directly to the "cached" resource if it's available and only call the service if it's not. So I'd put Varinsh in front of server A which runs the service and server B which stores the previously generated content versions. If it gets a request for a resource it hasn't got cached it'll try server B. Upon getting a 404 response it'll request the same resource from server A.
Can Varnish be configured in such a way with VCL? If not is there a solution like that you know about?
P.S. I don't want to send 302 redirects to the browser plus I don't have control over server B to make it send such redirects instead of 404's