@sharyn/browser.clearcaches
v1.0.10
Published
Clears all the caches used by service workers, and optionally reloads the page.
Downloads
4
Maintainers
Readme
🌹 clearCaches
clearCaches
: Clears all the caches
used by service workers.
Installation
npm i @sharyn/browser.clearcaches
# or
yarn add @sharyn/browser.clearcaches
You can alternatively install the @sharyn/browser package, or the entire sharyn library.
Arguments
[reload=false] (boolean): Reloads the page after emptying the caches.
[hardReload=true] (boolean): If reload
is true
, do a forced reload.
Returns
Promise
Example
const UpdateBanner = () => (
<div>
A new version of the app is available!
<a onClick={() => clearCaches(true)}>Click here to update</a>
</div>
)
Imports
Depending on the package you are using, you can import
or require
clearCaches
in the following ways:
// If you installed @sharyn/browser.clearcaches
import clearCaches from '@sharyn/browser.clearcaches' // smaller size, better for client bundles
// If you installed @sharyn/browser
import clearCaches from '@sharyn/browser/clearCaches' // smaller size, better for client bundles
import { clearCaches } from '@sharyn/browser' // more convenient in Node environments
// If you installed sharyn
import clearCaches from 'sharyn/browser/clearCaches' // smaller size, better for client bundles
import { clearCaches } from 'sharyn/browser' // more convenient in Node environments