{"id":45727,"library":"page-action-cache","title":"Page Action Cache - OpenClaw Extension","description":"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.","status":"active","version":"2026.21.1","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","openclaw","plugin","extension","browser","cache","typescript"],"install":[{"cmd":"npm install page-action-cache","lang":"bash","label":"npm"},{"cmd":"yarn add page-action-cache","lang":"bash","label":"yarn"},{"cmd":"pnpm add page-action-cache","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides the OpenClaw plugin framework and type definitions","package":"openclaw/plugin-sdk","optional":false}],"imports":[{"note":"ESM-only. CommonJS require will fail at runtime.","wrong":"const PageActionCache = require('page-action-cache')","symbol":"PageActionCache","correct":"import { PageActionCache } from 'page-action-cache'"},{"note":"Named export, not default.","wrong":"import PageSnapshotCache from 'page-action-cache'","symbol":"PageSnapshotCache","correct":"import { PageSnapshotCache } from 'page-action-cache'"},{"note":"Use 'import type' for type-only imports to avoid runtime errors, but it works at runtime if compiled.","wrong":"import { PluginConfig } from 'page-action-cache'","symbol":"PluginConfig","correct":"import type { PluginConfig } from 'page-action-cache'"}],"quickstart":{"code":"import { PageActionCache } from 'page-action-cache';\n\nconst cache = new PageActionCache({\n  enabled: true,\n  autoUseCache: true\n});\n\n// Store a snapshot\ncache.store('https://example.com', '<html>...</html>', { user: 'ref1' });\n\n// Retrieve a snapshot\nconst result = cache.retrieve('https://example.com');\nconsole.log(result); // { snapshot: '...', refs: { user: 'ref1' }, hit: true }\n\n// Get cache statistics\nconst stats = cache.getStats();\nconsole.log(stats);\n// { totalEntries: 1, totalHits: 1, hitRate: 100, avgHitCount: 1, cleanedEntries: 0 }\n\n// Clear cache\ncache.clear();","lang":"typescript","description":"Demonstrates instantiation, storing, retrieving, statistics, and clearing of the page cache."},"warnings":[{"fix":"Use a persistent caching solution (e.g., Redis) if data durability is required.","message":"Cache is in-memory only. All entries are lost when the Node.js process restarts. Not suitable for persistent caching across server restarts.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Monitor cache usage and adjust the LRU limit if needed (not configurable).","message":"Maximum cache size is 50 entries. Adding more will evict the least recently used entry silently.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"If custom TTL is needed, consider forking or wrapping the package.","message":"TTL is fixed at 5 minutes. There is no way to customize expiration time.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Upgrade Node.js to 22+ or use an older version of the package if available.","message":"Package requires Node.js 22+. Older Node versions will throw an error due to ESM and modern JS features.","severity":"breaking","affected_versions":">=2026.0.0"},{"fix":"Manually invalidate cache entries when content is updated.","message":"The cache does not detect page changes. It stores whatever snapshot is provided, even if the page content has changed.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'2026.21.1':29 '22':39 '5':25 '50':21 'action':2 'ai':73 'ai-driven':72 'automat':83 'browser':99 'cach':3,16,46,48,51,54,62,86,100 'cleanup':84 'clear':52 'driven':74 'entri':22 'esm':34 'evict':19 'expiri':27 'export':41 'extens':5,8,98 'generic':61 'hit':79 'hit-rat':78 'in-memori':11 'integr':64 'javascript':95 'lru':18 'max':20 'memori':13 'minut':26 'nativ':65 'node.js':38 'offer':77 'openclaw':4,7,67,96 'page':1,14,44,47,50,55 'persist':89 'plugin':69,97 'process':93 'provid':10 'rate':80 'refer':59 'reset':91 'restart':94 'role':58 'sdk':70 'ship':30 'snapshot':15,45,56 'stat':49 'statist':81 'target':37 'three':42 'tool':43 'ttl':24 'type':32 'typescript':31,101 'ui':76 'unlik':60 'use':33 'version':28 'web':75","created_at":"2026-06-07T12:56:26.101455+00:00","updated_at":"2026-06-07T12:56:26.101455+00:00","problems":[{"fix":"Use import statement in an ESM environment, or convert your project to ESM by adding 'type': 'module' in package.json.","cause":"Package is ESM-only, but user is trying to import with CommonJS require().","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/page-action-cache/dist/index.js not supported."},{"fix":"Use named import: import { PageActionCache } from 'page-action-cache'.","cause":"User imported default instead of named export, e.g., 'import PageActionCache from ...'.","error":"TypeError: pageActionCache.retrieve is not a function"},{"fix":"Install the SDK: npm install openclaw/plugin-sdk.","cause":"Missing peer dependency openclaw/plugin-sdk.","error":"Error: Cannot find module 'openclaw/plugin-sdk'"},{"fix":"Upgrade Node.js to version 22 or higher.","cause":"Node.js version is below 22.","error":"Error: The engine 'node' is incompatible with this module. Expected version '>=22'. Got '18.x.x'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"page-action-cache","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}