Frontend development with heavy backend API
Frontend development can get bit frustrating when working with heavy slow backend. In my case it’s an API served via HTTP. Solution? Throw in Varnish cache in between with a simple/dumb cache-all config:
backend default {
.host = "127.0.0.2";
.port = "80";
}
sub vcl_recv {
set req.backend = default;
return(lookup);
}
sub vcl_miss {
return(fetch);
}
sub vcl_hit {
return(deliver);
}
sub vcl_fetch {
set beresp.ttl = 24h;
set beresp.http.X-Cacheable = "YES";
unset beresp.http.Vary;
return(deliver);
}
sub vcl_deliver {
return(deliver);
}