Monorepo icon indicating copy to clipboard operation
Monorepo copied to clipboard

refreshLocalesCache() does not refresh the correct cache keys

Open SachaG opened this issue 1 year ago • 3 comments

If I'm not mistaken, surveyform now uses keys of the form localeWithStrings_en-US_..., but refreshLocalesCache() does not seem to refresh them.

Ideally, we would:

  • Rename all the localeWithStrings_* keys so they start with the name of the app, in this case surveyform_ – this is so that we can safely delete cached data for one app with no risk of affecting the others.
  • Get rid of the current surveyform_* and surveyform_*_converted keys, which I think are not used by surveyform anyway (double check that!) but still refreshed by that function.

SachaG avatar Jul 23 '24 00:07 SachaG

First step on https://github.com/Devographics/Monorepo/pull/406

  • I removed "localeConverted"
  • I've added the appName to "localeWithStrings" using a pattern similar to other cache_keys
  • I am using the cache key directly rather than loading the locale

Not yet done:

  • I see keys like "surveyform_localeWithStrings_en-US_accounts,common,js2023,state_of_js,surveys". This is indeed incorrect, as locales should be loaded using a hiearchy, so "surveyform_localeWithStrings_en-US_accounts,common,surveys" for instance and then maybe the survey specific locales. That's probably a regression because the token optimization system was relying on page-level list of tokens, while previously I was relying on layouts, which allowed this kind of hierarchy. Will dig further.
  • I need to remove calls to the older API to get rid of the old cache key, it may still be used

So still need a bit of cleanup before I close the issue but you can already merge the PR.

eric-burel avatar Jul 25 '24 17:07 eric-burel

@SachaG should be ok for surveyform, it builds and do not seem to be buggy, you can test and merge #406

eric-burel avatar Jul 26 '24 17:07 eric-burel

I've also cleaned up homepage and chart that were calling the deprecated "fetchLocale" method

eric-burel avatar Jul 26 '24 17:07 eric-burel