@sharyn/browser.clearcaches
TypeScript icon, indicating that this package has built-in type declarations

1.0.10 • Public • Published

🌹 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

This package is part of Sharyn, a collection of utilities and helpers.

Package Sidebar

Install

npm i @sharyn/browser.clearcaches

Weekly Downloads

2

Version

1.0.10

License

MIT

Unpacked Size

4.64 kB

Total Files

5

Last publish

Collaborators

  • sharyn