Skip to content

Commit

Permalink
docs(README): improve caching explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
JuroUhlar committed Nov 13, 2023
1 parent 403710d commit 9e109d4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions README.md
Expand Up @@ -201,11 +201,16 @@ See the full code example in the [examples folder](https://github.com/fingerprin

## Caching strategy

Fingerprint Pro usage is billed per API call. To reduce API calls, it is a good practice to [cache identification results](https://dev.fingerprint.com/docs/caching-visitor-information). The SDK uses SessionStorage to cache results by default.
Fingerprint Pro usage is billed per API call. To avoid unnecessary API calls, it is a good practice to cache identification results. By default, the SDK uses `sessionStorage` to cache results.

> :warning: **WARNING** If you use data from `extendedResult`, pay additional attention to caching strategy.
>
> Some fields from the [extendedResult](https://dev.fingerprint.com/docs/js-agent#extendedresult) (e.g., `ip` or `lastSeenAt`) might change over time for the same visitor. If you need to get the latest results, pass `{ignoreCache: true}` to the `getData()` function.
* Specify the `cacheLocation` prop on `<FpjsProvider>` to instead store results in `memory` or `localStorage`. Use `none` to disable caching completely.
* Specify the `cache` prop on `<FpjsProvider>` to use your custom cache mechanism instead. For more details, see [Creating a custom cache](https://github.com/fingerprintjs/fingerprintjs-pro-spa#creating-a-custom-cache)
in the Fingerprint Pro SPA repository (a lower-level Fingerprint library used by this SDK).
* Pass `{ignoreCache: true}` to the `getData()` function to ignore cached results for that specific API call.

> [!NOTE]
> If you use data from [`extendedResult`](https://dev.fingerprint.com/docs/js-agent#extendedresult), pay additional attention to your caching strategy.
> Some fields, for example, `ip` or `lastSeenAt`, might change over time for the same visitor. Use `getData({ ignoreCache: true })` to fetch latest identification results.
## Error handling

Expand Down

0 comments on commit 9e109d4

Please sign in to comment.