-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update dns-in-google-sheets.mdx to add caching in NSLookup #17298
Conversation
…kup function. Adding internal caching of the results on the NSLookup function to limit the number of the DNS resolver requests and speed up the results - especially in larger Google Sheets.
src/content/docs/1.1.1.1/other-ways-to-use-1.1.1.1/dns-in-google-sheets.mdx
Show resolved
Hide resolved
type = type.toUpperCase(); | ||
domain = domain.toLowerCase(); | ||
|
||
if (usecache == true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be if (usecache)
as usecache
is validated to be boolean.
src/content/docs/1.1.1.1/other-ways-to-use-1.1.1.1/dns-in-google-sheets.mdx
Show resolved
Hide resolved
@@ -12,7 +12,7 @@ import { Details } from "~/components" | |||
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: | |||
|
|||
```js | |||
function NSLookup(type, domain) { | |||
function NSLookup(type, domain, usecache = true, cachettl = 1800) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value for usecache
should be false, since correctness should be preferred over performance. Users who want to change that are free to do so.
src/content/docs/1.1.1.1/other-ways-to-use-1.1.1.1/dns-in-google-sheets.mdx
Show resolved
Hide resolved
- Change minCacheTTL from Math.min to Math.max - Change default value of cachettl from 1800 to 30.
Sorry for the confusing, I think our TTL calculation is still not right. This would be the changes I'd like to make before we can merge it. Basically, use the minimal TTL from records, but clamp the lower bound at the minCacheTTL (which is 30 seconds). Also replaced
|
Applying changes from cloudflare#17298 (comment) + rename usecache to useCache to make all variables/constants follow lowerCamelCase.
Thanks @hunts. I have committed the patch, and at the same time renamed usecache to useCache, so all variables / constants are following lowerCamelCase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick updates. Looks good to me now.
Congratulations @beltofte, the maintainer of this repository has issued you a holobyte! Here it is: https://holopin.io/holobyte/cm2n4dctz16090cldevclq0gd This badge can only be claimed by you, so make sure that your GitHub account is linked to your Holopin account. You can manage those preferences here: https://holopin.io/account. |
* Update dns-in-google-sheets.mdx to include cache support in the NSLookup function. Adding internal caching of the results on the NSLookup function to limit the number of the DNS resolver requests and speed up the results - especially in larger Google Sheets. * Process suggested changes for Answer TTL and usecache disabled by default * Change how minCacheTTL is set - Change minCacheTTL from Math.min to Math.max - Change default value of cachettl from 1800 to 30. * Minor code style - change tab to spaces. * Apply patch + rename usecache to useCache Applying changes from #17298 (comment) + rename usecache to useCache to make all variables/constants follow lowerCamelCase. * Remove outdated cache value from descriptive paragraph * Replace one remaining var by const --------- Co-authored-by: Rebecca Tamachiro <rtamachiro@cloudflare.com>
Adding internal caching of the results on the NSLookup function to limit the number of the DNS resolver requests and speed up the results - especially in larger Google Sheets.
Summary
The NSLookup function for Google Sheets provided in the original documentation page does not support internal caching of the results. This can lead to issues in Google Sheets with many calls to the function - this includes error 400 from the https://cloudflare-dns.com/dns-query if you use it too much.
It is possible to disable caching and control the cache TTL via arguments in the NSLookup function.
Screenshots (optional)
Documentation checklist