Google Sheets natively controls how the functions recalculate according to different behaviours (modifying cells, opening the spreadsheet, …). This is why, sometimes, you enter your spreadsheet and see your functions recalculating and your data loading.
To better control this, ImportFromWeb caches the webpages it fetches. So whenever Google Sheets refreshes the =IMPORTFROMWEB() functions, the content is retrieved from the cache and it is not counted as new requests.
By default, pages and data are cached for 1 week. The cache_lifespan option enables to overwrite and extend (or reduce) the default cache setting (from 1 hour and up to 4 weeks). You can define the time in hours, days or weeks during which you want to keep your data before it is fetched again. It helps you to control your credits usage when you do not need to update your data frequently.
Control the cache_lifespan from the =IMPORTFROMWEB formulas
The cache_lifespan option is set the 3d parameter into your =IMPORTFROMWEB() formulas.
You can use the cache_lifespan option by inputting the duration in hours, days or weeks and using different syntaxes like 10h
, 10hours
, 10 hours
or even just 10
.
Bear in mind that the function will not necessarily update directly after the cache expires but only when Google Sheets lets the function recalculate.
As any other options of IMPORTFROMWEB, there are 2 ways to call the cache_lifespan option:
=IMPORTFROMWEB(data_sources, selectors, "cache_lifespan:2 days")
or
A | B | |
---|---|---|
1 | cache_lifespan | 2 days |
2 | ||
3 | =IMPORTFROMWEB(data_sources, selectors, A1:B1) |
Control the cache_lifespan from the sidebar
Alternatively, the cache can be set directly from the sidebar of the add-on:
Please note that the cache set in the sidebar applies to your current spreadsheet only.
Of course, whatever your cache setting is, you can always decide to update your data by re-executing the =IMPORTFROMWEB() functions from the sidebar. Select the cells that contain the formulas in your spreadsheet and press RUN from the “Monitor” tab.