1.4.15 • Published 1 day ago

@microlink/ping-url v1.4.15

Weekly downloads
62
License
MIT
Repository
github
Last release
1 day 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 day ago

1.4.14

2 months ago

1.4.13

2 months ago

1.4.12

3 months ago

1.4.9

8 months ago

1.4.11

7 months ago

1.4.10

7 months ago

1.4.8

12 months ago

1.4.6

1 year ago

1.4.5

1 year ago

1.4.7

1 year ago

1.4.4

2 years ago

1.4.3

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.25

2 years ago

1.3.24

2 years ago

1.3.23

2 years ago

1.3.22

3 years ago

1.3.21

3 years ago

1.3.20

3 years ago

1.3.19

3 years ago

1.3.18

3 years ago

1.3.17

3 years ago

1.3.16

3 years ago

1.3.15

3 years ago

1.3.14

3 years ago

1.3.13

3 years ago

1.3.12

3 years ago

1.3.11

3 years ago

1.3.10

4 years ago

1.3.9

4 years ago

1.3.8

4 years ago

1.3.7

4 years ago

1.3.6

4 years ago

1.3.5

4 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.1

5 years ago

0.0.1

5 years ago