Skip to content

Commit 9711bc0

Browse files
Process suggested changes for Answer TTL and usecache disabled by default
1 parent dc32f5c commit 9711bc0

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/content/docs/1.1.1.1/other-ways-to-use-1.1.1.1/dns-in-google-sheets.mdx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Details } from "~/components"
1212
1.1.1.1 works directly inside Google Sheets. To get started, create a [Google Function](https://developers.google.com/apps-script/guides/sheets/functions) with the following code:
1313

1414
```js
15-
function NSLookup(type, domain, usecache = true, cachettl = 1800) {
15+
function NSLookup(type, domain, usecache = false, cachettl = 1800) {
1616

1717
if (typeof type == 'undefined') {
1818
throw new Error('Missing parameter 1 dns type');
@@ -33,7 +33,7 @@ function NSLookup(type, domain, usecache = true, cachettl = 1800) {
3333
type = type.toUpperCase();
3434
domain = domain.toLowerCase();
3535

36-
if (usecache == true) {
36+
if (usecache) {
3737
// Cache key and hash
3838
cacheKey = domain + "@" + type;
3939
cacheHash = Utilities.base64Encode(cacheKey);
@@ -89,10 +89,15 @@ function NSLookup(type, domain, usecache = true, cachettl = 1800) {
8989

9090
var outputString = outputData.join(',');
9191

92-
if (usecache == true) {
92+
if (usecache) {
9393
cache.put(cacheBinKey, outputString, cachettl);
9494
}
95-
95+
96+
for (var i in response.Answer) {
97+
outputData.push(response.Answer[i].data);
98+
minCacheTTL = Math.min(minCacheTTL, response.Answer[i].TTL);
99+
}
100+
96101
return outputString;
97102
}
98103
```
@@ -101,7 +106,7 @@ function NSLookup(type, domain, usecache = true, cachettl = 1800) {
101106

102107
When you feed the function `NSLookup` a record type and a domain, you will get a DNS record value in the cell you called `NSLookup`.
103108

104-
The function by default cache the returned DNS record value for 1800 seconds, to limit the number of DNS lookups and speed up the results especially in larger Google Sheets. Both the cache usage and the cache TTL can be controlled in argument 3 and 4.
109+
To limit the number of DNS lookups and speed up the results (especially in larger Google Sheets), you can cache the returned DNS record value for 1800 seconds. Both the cache usage and the cache TTL can be controlled in arguments 3 and 4, respectively.
105110

106111
<Details header="Supported DNS record types">
107112

0 commit comments

Comments
 (0)