---
title: "Exploring Apps Script CacheService Limits: Empirical Findings and FIFO Eviction Gotchas"
author: "Martin Hawksey"
date: 2026-10-23T10:43:58+00:00
modified: 2026-10-23T10:44:05+00:00
canonical_url: https://pulse.appsscript.info/p/2026/10/exploring-apps-script-cacheservice-limits-empirical-findings-and-fifo-eviction-gotchas/
markdown_url: https://pulse.appsscript.info/p/2026/10/exploring-apps-script-cacheservice-limits-empirical-findings-and-fifo-eviction-gotchas.md
categories:
  - "Gotchas"
  - "Intermediate"
  - "Level"
tags:
  - "justin.poehnelt.com"
featured_image: https://pulse.appsscript.info/files/2026/10/cacheservice.jpg
description: "Explore undocumented Google Apps Script CacheService limits, including FIFO eviction gotchas, the 100-item batch drop over 1,000 keys, and how to prevent cache misses."
---

# Exploring Apps Script CacheService Limits: Empirical Findings and FIFO Eviction Gotchas

![Exploring Apps Script CacheService Limits: Empirical Findings and FIFO Eviction Gotchas](https://pulse.appsscript.info/files/2026/10/cacheservice.jpg)

> Caching is a critical strategy for optimizing performance in Google Apps Script properties, especially when dealing with slow APIs or heavy computations. The built-in `CacheService` provides a simple key-value store, but its documentation leaves several “edge cases” and failure scenarios vague. While the documentation states a maximum value size of 100KB, it doesn’t explicitly detail what happens when you hit the Apps Script CacheService key length limit or throw odd types at it. In this post, we’ll write a script to empirically test these limits … and explore how the service behaves under stress.

Google Workspace alum Justin Poehnelt (whose open-source work many in the community will recognise from the [Google Workspace CLI (`gws`)**](https://github.com/googleworkspace/cli)) has shared a great investigation in [Apps Script CacheService Limits**](https://justin.poehnelt.com/posts/exploring-apps-script-cacheservice-limits/). As noted by Justin, while the official [`CacheService`**](https://developers.google.com/apps-script/reference/cache/cache) documentation states some of the limits like key value size and the 1,000 cacheable item limit, it leaves out some important details. One finding I think every Apps Script developer should know about is the mechanics of cache eviction when you go over 1,000 items. When you reach this limit, rather than one-in, one-out, `CacheService` will drop approximately 100 of the oldest items.

For developers who use other caching tools like Redis or Memcached, which primarily rely on Least Recently Used (LRU) where frequently accessed keys stay alive, another key finding is that `CacheService` uses First-In, First-Out (FIFO). This means `CacheService` throws away your oldest data even if you are regularly using it in your script. I’m sure most developers are defensively using `CacheService` to cache values if not found. To keep “hot” keys from aging out of the queue, Justin shares a function in his post to manually remove and re-insert them.

What I really like about Justin’s post is the empirical approach, writing a small test harness to verify how the Apps Script runtime behaves in practice rather than taking standard cache behaviour for granted. As more developers use the Gemini side panel in the Apps Script IDE or AI coding assistants to vibe-code Workspace automations, having Justin’s posts and ones like it hopefully nudge these tools in the right direction regarding this nuanced behaviour. Understanding these runtime quirks upfront can save a lot of head-scratching when debugging intermittent cache misses in production.

Follow the source link for the full walkthrough and test outputs.

Source: [Apps Script CacheService Limits — Justin Poehnelt**](https://justin.poehnelt.com/posts/exploring-apps-script-cacheservice-limits/)

---

*Published by [Martin Hawksey](https://pulse.appsscript.info/p/author/admin/) on [Pulse](https://pulse.appsscript.info/). Original article: [https://pulse.appsscript.info/p/2026/10/exploring-apps-script-cacheservice-limits-empirical-findings-and-fifo-eviction-gotchas/](https://pulse.appsscript.info/p/2026/10/exploring-apps-script-cacheservice-limits-empirical-findings-and-fifo-eviction-gotchas/)*
