szmarczak / cacheable-lookup

A cacheable dns.lookup(…) that respects TTL :tada:
MIT License
193 stars 29 forks source link

[Question] How to install globally properly #44

Closed Kikobeats closed 3 years ago

Kikobeats commented 3 years ago

Hello,

I was wondering if global installation needs to wrap just HTTP agent or also HTTPS as well?

const http = require('http');
const CacheableLookup = require('cacheable-lookup');
const cacheable = new CacheableLookup({
    // Set any custom options here
});
cacheable.servers = [
    // Put your DNS servers of choice here
];

// Configure this to be used by a single request:
http.get("http://example.com", {
    lookup: cacheable.lookup
});

Essentially, I should do this:

cacheable.install(http.globalAgent);

or also this?

cacheable.install(http.globalAgent);
cacheable.install(https.globalAgent);
szmarczak commented 3 years ago

Both, as http != https

Kikobeats commented 3 years ago

Thanks for clarifying; I created a PR just to help to clarify other people