Registry / storage / page-action-cache

page-action-cache

JSON →
library2026.21.1jsnpmunverified

An OpenClaw extension that provides in-memory page snapshot caching with LRU eviction (max 50 entries) and TTL (5-minute expiry). Version 2026.21.1 ships TypeScript types, uses ESM only, and targets Node.js 22+. It exports three tools (page_snapshot_cache, page_cache_stats, page_cache_clear) for caching page snapshots and role references. Unlike generic caches, this integrates natively with OpenClaw's plugin SDK and AI-driven Web UI, offering hit-rate statistics and automatic cleanup. The cache is not persistent and resets on process restart.

npm install page-action-cache
INSTALL
IMPORT
SIG · PAGE-ACTION-CACHE
P
page-action-cache
storagejavascriptv2026.21.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PageActionCache
import { PageActionCache } from 'page-action-cache'
const PageActionCache = require('page-action-cache')
ESM-only. CommonJS require will fail at runtime.
PageSnapshotCache
import { PageSnapshotCache } from 'page-action-cache'
import PageSnapshotCache from 'page-action-cache'
Named export, not default.
PluginConfig
import type { PluginConfig } from 'page-action-cache'
import { PluginConfig } from 'page-action-cache'
Use 'import type' for type-only imports to avoid runtime errors, but it works at runtime if compiled.

Demonstrates instantiation, storing, retrieving, statistics, and clearing of the page cache.

import { PageActionCache } from 'page-action-cache'; const cache = new PageActionCache({ enabled: true, autoUseCache: true }); // Store a snapshot cache.store('https://example.com', '<html>...</html>', { user: 'ref1' }); // Retrieve a snapshot const result = cache.retrieve('https://example.com'); console.log(result); // { snapshot: '...', refs: { user: 'ref1' }, hit: true } // Get cache statistics const stats = cache.getStats(); console.log(stats); // { totalEntries: 1, totalHits: 1, hitRate: 100, avgHitCount: 1, cleanedEntries: 0 } // Clear cache cache.clear();
Debug
Known issues
gotchaCache is in-memory only. All entries are lost when the Node.js process restarts. Not suitable for persistent caching across server restarts.
fix
Use a persistent caching solution (e.g., Redis) if data durability is required.
affects: >=0.0.0
gotchaMaximum cache size is 50 entries. Adding more will evict the least recently used entry silently.
fix
Monitor cache usage and adjust the LRU limit if needed (not configurable).
affects: >=0.0.0
gotchaTTL is fixed at 5 minutes. There is no way to customize expiration time.
fix
If custom TTL is needed, consider forking or wrapping the package.
affects: >=0.0.0
breakingPackage requires Node.js 22+. Older Node versions will throw an error due to ESM and modern JS features.
fix
Upgrade Node.js to 22+ or use an older version of the package if available.
affects: >=2026.0.0
gotchaThe cache does not detect page changes. It stores whatever snapshot is provided, even if the page content has changed.
fix
Manually invalidate cache entries when content is updated.
affects: >=0.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/page-action-cache/dist/index.js not supported.
Package is ESM-only, but user is trying to import with CommonJS require().
fix
Use import statement in an ESM environment, or convert your project to ESM by adding 'type': 'module' in package.json.
TypeError: pageActionCache.retrieve is not a function
User imported default instead of named export, e.g., 'import PageActionCache from ...'.
fix
Use named import: import { PageActionCache } from 'page-action-cache'.
Error: Cannot find module 'openclaw/plugin-sdk'
Missing peer dependency openclaw/plugin-sdk.
fix
Install the SDK: npm install openclaw/plugin-sdk.
Error: The engine 'node' is incompatible with this module. Expected version '>=22'. Got '18.x.x'
Node.js version is below 22.
fix
Upgrade Node.js to version 22 or higher.
Upgrade
Version history
2026.21.1latest on npm
Audit
Dependencies
openclaw/plugin-sdkrequiredProvides the OpenClaw plugin framework and type definitions
Agent activity
11 hits · last 30 days
node
10
Amazon
1
Resources
page-action-cache — npm install page-action-cache · libregistry