Registry / storage / cordova-plugin-cache-clear

cordova-plugin-cache-clear

JSON →
library1.3.8jsnpmunverified

A Cordova plugin (v1.3.8, last updated 2017) that clears the WebView cache on Android and iOS. It exposes a single `window.CacheClear` function requiring a success and error callback. On iOS it deletes temporary files (downloaded images), while on Android it wipes persistent data including localStorage, stored files, and cache. Compatibility requires Cordova >=6.1.1 and Android >=4.1 or iOS >=6.0. No updates since 2017; not recommended for new projects.

npm install cordova-plugin-cache-clear
INSTALL
IMPORT
SIG · CORDOVA-PLUGIN-CAC
C
cordova-plugin-cache-clear
storagejavascriptv1.3.8
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.

window.CacheClear
window.CacheClear(successCallback, errorCallback)
CacheClear(successCallback, errorCallback)
Must be called after 'deviceready' event; otherwise window.CacheClear may not be defined.
Plugin Installation
cordova plugin add cordova-plugin-cache-clear
npm install cordova-plugin-cache-clear
Use cordova CLI, not npm; the plugin is not intended for direct npm usage.
Platform Usage
document.addEventListener('deviceready', ...)
The plugin only works inside a Cordova app; calling CacheClear without 'deviceready' may fail.

Demonstrates installation, 'deviceready' event, callback usage, and a Promise wrapper for the CacheClear function.

// Install: cordova plugin add cordova-plugin-cache-clear // Then in your code: document.addEventListener('deviceready', function() { var success = function(status) { alert('Cache cleared: ' + status); }; var error = function(status) { alert('Error clearing cache: ' + status); }; window.CacheClear(success, error); }); // Example with Promise wrapper: function clearCache() { return new Promise(function(resolve, reject) { window.CacheClear(resolve, reject); }); } // Usage: clearCache().then(function(status) { console.log('Success:', status); }).catch(function(err) { console.error('Error:', err); });
Debug
Known issues
gotchaCacheClear on Android deletes all local persistent data including localStorage, app files, and SQLite databases—not just cache.
fix
Do not use if you need to preserve user data; consider alternative Android-specific solutions.
affects: >=0.0.0
deprecatedPlugin is unmaintained since 2017 and not updated for modern Cordova versions (12+).
fix
Use cordova-plugin-cleartext or custom fork; no official replacement.
affects: >=1.3.8
gotchaThe plugin may not work with newer Android/iOS WebView implementations; behavior is undefined.
fix
Test thoroughly on target platforms; consider native clearing methods.
affects: >=1.3.8
Errors
Common errors & fixes
window.CacheClear is not a function
Called before 'deviceready' event or plugin not properly installed.
fix
Ensure you call within deviceready listener: document.addEventListener('deviceready', ...). Verify plugin added with 'cordova plugin list'.
Error: CacheClear is not defined
Using CacheClear without window prefix in a TypeScript or strict mode environment.
fix
Use window.CacheClear (or cast as any: (window as any).CacheClear).
Plugin not found
Running 'npm install' instead of 'cordova plugin add'.
fix
Use: cordova plugin add cordova-plugin-cache-clear
Upgrade
Version history
1.3.8latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
26 hits · last 30 days
node
24
OpenAI (training)
1
Resources
cordova-plugin-cache-clear — npm install cordova-plugin-cache-clear · libregistry