Registry / mobile / capacitor-plugin-webview-cache-extended

capacitor-plugin-webview-cache-extended

JSON →
library3.0.0jsnpmunverified

A Capacitor plugin that clears the Android WebView cache by invoking the native WebView.clearCache(true) method. Useful when images on the server are replaced but keep the same filename, causing the WebView to show stale cached images. Version 3.0.0 requires @capacitor/core ^6.0.0. The plugin is minimal, focused on a single method, and ships TypeScript types. It currently only supports Android.

npm install capacitor-plugin-webview-cache-extended
INSTALL
IMPORT
SIG · CAPACITOR-PLUGIN-W
C
capacitor-plugin-webview-cache-extended
mobilejavascriptv3.0.0
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.

WebViewCache
import { WebViewCache } from 'capacitor-plugin-webview-cache-extended'
import { Plugins } from '@capacitor/core'; const { WebViewCache } = Plugins;
Direct import from plugin package is preferred; accessing via Plugins is deprecated.
WebViewCache
import { WebViewCache } from 'capacitor-plugin-webview-cache-extended'
const WebViewCache = require('capacitor-plugin-webview-cache-extended').WebViewCache;
CommonJS require works but without destructuring the default export can cause issues if the package is ESM-only. TypeScript types are included.
clearCache
import { clearCache } from 'capacitor-plugin-webview-cache-extended'
Named export for the method; also available as WebViewCache.clearCache().

Shows how to import and use the plugin to clear the Android WebView cache.

import { WebViewCache } from 'capacitor-plugin-webview-cache-extended'; async function clearAppCache() { await WebViewCache.clearCache(); console.log('WebView cache cleared'); } clearAppCache();
Debug
Known issues
gotchaPlugin only works on Android. Calls on iOS or other platforms will silently fail or throw an error if not properly guarded.
fix
Check platform before calling: if (Capacitor.isPluginAvailable('WebViewCache')) { ... }
affects: >=3.0.0
breakingIn version 3.0.0, the plugin no longer exports as part of @capacitor/core Plugins. Direct import from the package is required.
fix
Change imports from 'import { Plugins } from '@capacitor/core' to 'import { WebViewCache } from 'capacitor-plugin-webview-cache-extended'
affects: >=3.0.0
Errors
Common errors & fixes
Error: WebViewCache is not a constructor
Using require() without destructuring the exported object.
fix
Use import { WebViewCache } from 'capacitor-plugin-webview-cache-extended' or const { WebViewCache } = require('capacitor-plugin-webview-cache-extended')
TypeError: Cannot read property 'clearCache' of undefined
Plugin not registered or not available on the current platform.
fix
Ensure the plugin is installed and run npx cap sync, then check Capacitor.isPluginAvailable('WebViewCache') before calling.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
@capacitor/coreoptionalpeer dependency for Capacitor plugin API
Agent activity
59 hits · last 30 days
node
52
Resources
capacitor-plugin-webview-cache-extended — npm install capacitor-plugin-webview-cache-extended · libregistry