urbica / galton

Lightweight Node.js isochrone map server
https://galton.urbica.co
MIT License
272 stars 36 forks source link

Response caching #186

Open MichielDeMey opened 6 years ago

MichielDeMey commented 6 years ago

We'd need heavy response caching based on the lat/lng since they take quite a while to compute (up to 5s) for a certain coordinate pair.

Would you be up to review a PR containing https://github.com/coderhaoxin/koa-redis-cache? Or do you have any other suggestions pertaining to result caching?

glifchits commented 6 years ago

Does it make sense to cache isochrones? You would need to round the lat/lng for a cache key that makes sense, and that might cause issues for some use cases (e.g. if you're generating isochrones in a small area within a city, and you move the isochrone origin even a small amount, I'd expect the isochrone to change a little bit; but if it were cached with decreased accuracy coordinates then it wouldn't always change).

I personally would hesitate to use Galton if it forced me to adopt Redis as a dependency just to cache isochrones -- for what we use Galton for, caching would not be helpful.

MichielDeMey commented 6 years ago

You make a valid point, and ideally the caching middleware would be optional. It might just be best to pass on this feature request altogether and move caching external to this project.

E.g. By using Varnish or an external microservice with the sole purpose of building a cache.