window.clearCache() to remove cached translations from localStorage. You can clear the cache for all languages at once or target specific language codes.
The widget stores translations in localStorage using the prefix jss- combined with the target language code as the cache key (e.g., jss-fr for French). Clearing the cache forces the widget to fetch fresh translations from the JigsawStack API on the next translation request.
Signature
Parameters
Array of language codes to clear from the cache. Pass an empty array
[] to clear cached translations for all languages.Callback called after the cache is cleared successfully.
Callback called if clearing the cache fails. Receives an
Error object.Return value
This function returnsvoid. Use the onComplete callback to react after the cache has been cleared.
Examples
Cache storage
Translations are cached inlocalStorage using the prefix jss-. The cache key for each language is jss-<langcode> (e.g., jss-fr for French). Each key stores a JSON map of original text to translated text for all content translated to that language.
When to use
Clear the cache when:- You have updated the content on your page and want users to receive fresh translations.
- Previously cached translations are stale or incorrect.
- You want to force the widget to re-fetch all translations from the API on the next request.
After the cache is cleared, the widget re-fetches translations from the JigsawStack API the next time a translation is requested. Each re-fetch counts against your API usage.