Returns a cache tied to the current spreadsheet or doc.
class CacheService method .getDocumentCache()
CacheService is the Apps Script service.
.getDocumentCache() is the method name you will see after a dot in your code.
What it does
Why it's used
- Cache lookups for this file only, like exchange rates for this model.
- Avoid recomputing heavy sheet-specific summaries.
Common errors
- Forgetting parentheses on getDocumentCache. Write CacheService.getDocumentCache(), not CacheService.getDocumentCache or getDocumentCache by itself.
- Skipping dots between chained calls. Each step needs a dot, like CacheService.getDocumentCache().
- Adding spaces where they do not belong. Write CacheService.getDocumentCache(), not CacheService .getDocumentCache(), CacheService.getDocumentCache (), or CacheService . getDocumentCache().
- Wrong capitalization. Use CacheService and getDocumentCache, not cacheservice or getdocumentcache.
Explore
Related methods
-
.getScriptCache()
Returns a cache shared by all users of the script.
-
.getUserCache()
Returns a cache private to the current user.
-
.get()
Reads a cached value by key.
-
.remove()
Deletes a cached value by key.
-
.put()
Stores a value in the cache for a set time.
More Apps Script
Better Sheets tutorials
No tagged tutorials yet. Fetch Apps Script from the harvest table and this page fills automatically.