Layout Cache
The Rust LayoutEngine caches Taffy layout results in a 2-slot LRU cache (one for header height, one for row height). Scrolling reuses cached column positions instead of recomputing Taffy layout every frame.
Use engineRef to access invalidateLayout() — forces cache clear so the next frame recomputes from scratch. Changing layout props (flex-direction, gap, etc.) automatically causes a cache miss.
flex-direction:
gap:
Grid API
Cache Log
Click "Benchmark" to compare cached vs uncached performance, or "invalidateLayout()" to manually clear the cache.
How the cache works:
- 2-slot LRU — one for header height, one for row height (both hit on every frame)
- Key = hash of all column + container + viewport_width + row_height + line_height
- Cache hit = skip Taffy tree build + compute_layout entirely
- Scrolling only changes scroll_top (not a cache key), so layout is always cached during scroll
- Changing flex-direction or gap = automatic cache miss = fresh Taffy computation