cache url normaliser
Express middleware to populate a
res.cacheobject with consistent URL parsing for use in cache keys.
This simple middleware module provides an extra layer of URL parsing to provide an object useful for setting/getting cache keys within the request/response cycle. It normalises query string objects and provides suitable base and path strings. The resulting object is useful for finer granular cache keys in the context of an API server.
For example all of the following:
Example Use (with Redis
For example in the sample
res.cache above, we could use the concatenation of
endpoint) as the
endpoint?a=1&c=12&order=asc&y=some_value&z=67) as the
field and the data response from whatever data source as the
Nested properties (using
/shoes?order=desc&shoe[color]=blue&shoe[type]=converse as described here won't be parsed correctly.