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

Returns a cache tied to the current spreadsheet or doc.

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

Better Sheets tutorials

No tagged tutorials yet. Fetch Apps Script from the harvest table and this page fills automatically.