1.4.15 • Published 1 year ago

@microlink/ping-url v1.4.15

Weekly downloads
62
License
MIT
Repository
github
Last release
1 year ago

Last version Coverage Status NPM Status

Fast DNS resolution caching results for a while.

Motivation

Ping an URL for getting the canonical URL and store the result into a cache, respecting a Time-to-Live (TTL) for the next lookup.

Suggested TTL could be:

  • Very Short: 300 seconds (5 minutes).
  • Short: 3600 seconds (1 hour).
  • Long: 86400 seconds (24 hours).
  • Insanity: 604800 seconds (7 days).

This library support any data storage provided by keyv.

Install

$ npm install @microlink/ping-url --save

Usage

const createPingUrl = require('@microlink/ping-url')
const cache = new Map()
const pingUrl = createPingUrl({ store: cache, ttl: 3600 })

;(async () => {
  await pingUrl('https://example.com') // MISS, do the request
  await pingUrl('https://example.com') // HIT, serve from cache!
})()

The payload returned by pingUrl will be response but without any stream object there.

API

createPingUrl(keyvOptions, memoOpts) → pingUrl(url, gotOpts)

keyvOptions

See keyv#options.

memoOpts

See @keyvhq/memoize.

gotOpts

Type: object

Any option provided here will passed to got#options.

License

@microlink/ping-url © Microlink, released under the MIT License. Authored and maintained by Kiko Beats with help from contributors.

microlink.io · GitHub microlinkhq · Twitter @microlinkhq

1.4.15

1 year ago

1.4.14

1 year ago

1.4.13

1 year ago

1.4.12

1 year ago

1.4.9

2 years ago

1.4.11

2 years ago

1.4.10

2 years ago

1.4.8

2 years ago

1.4.6

2 years ago

1.4.5

2 years ago

1.4.7

2 years ago

1.4.4

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.25

3 years ago

1.3.24

3 years ago

1.3.23

3 years ago

1.3.22

4 years ago

1.3.21

4 years ago

1.3.20

4 years ago

1.3.19

4 years ago

1.3.18

4 years ago

1.3.17

4 years ago

1.3.16

4 years ago

1.3.15

4 years ago

1.3.14

4 years ago

1.3.13

4 years ago

1.3.12

4 years ago

1.3.11

5 years ago

1.3.10

5 years ago

1.3.9

5 years ago

1.3.8

5 years ago

1.3.7

5 years ago

1.3.6

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.1

6 years ago

0.0.1

6 years ago