jperelli / osm-static-maps

Openstreetmap static maps is a nodejs lib, CLI and server open source inspired on google static map service
http://osm-static-maps.herokuapp.com/
GNU General Public License v2.0
160 stars 52 forks source link

Add cache #11

Open jperelli opened 4 years ago

jperelli commented 4 years ago

Think on how to add a directory/redis/memcache cache so that this can be used as a <img src="..."> tag more efficiently. Maybe add a cache param like

this module looks good enough https://www.npmjs.com/package/cache-manager and this one to build the key from the options object https://www.npmjs.com/package/json-stable-stringify

pascalroget commented 4 years ago

as in - caching the binary images? If so, this will probably need an expires param as well

jperelli commented 4 years ago

Right, caching the binary images using the params (or hash of params) as key of the cache. That way only the first time the image is generated, but the next times is requested, the library just uses the cache to get and return the image fast.

And yes, I'll add an expires or timeout param for it to be auto purged