Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically clear the cache when the user switches collections or logs out #6116

Closed
grantfitzsimmons opened this issue Jan 17, 2025 · 0 comments · Fixed by #6148 · May be fixed by #6178
Closed

Automatically clear the cache when the user switches collections or logs out #6116

grantfitzsimmons opened this issue Jan 17, 2025 · 0 comments · Fixed by #6148 · May be fixed by #6178
Assignees
Labels
2 - User Interface Issues that are related to the user interface or user experience.
Milestone

Comments

@grantfitzsimmons
Copy link
Member

grantfitzsimmons commented Jan 17, 2025

We have encountered several significant issues due to how Specify caches information from the stored /context/system_info.json endpoint.

A long-running consequence of us not doing this is #3160, and more recently this became a big deal with #6096

Neither of these issues are resolved yet, but @melton-jason has a simple solution:

To fix these issues, the cache should be cleared when:

  • A user chooses a collection.
  • A user logs out.

The Issue can come up WAY more frequently than you might think if the database has at least one geo discipline and one non-geo discipline.

Due to the caching behavior, you can even easily recreate #6064!

See my below videos recreating both this Issue and #6064, both times in a new incognito tab (nothing initially cached).

Logging into non-geo/paleo discipline prevents it from showing for paleo/geo collections

no_age_in_paleo.mov

Logging into geo/paleo disciplines shows Age for non-paleo/geo collections

age_in_nonpaleo.mov

What's worse is that you need to clear your cache and/or log out multiple times for the value to completely clear from the cache!


The Issue here is that to determine the discipline type, Specify fetches the information from the stored /context/system_info.json endpoint

const disciplineType =
getSystemInfo().discipline_type?.toLowerCase();

export const fetchContext = load<SystemInfo>(
'/context/system_info.json',
'application/json'
).then((data) => {
systemInfo = data;
if (systemInfo.stats_url !== null)
ping(
formatUrl(
systemInfo.stats_url,
{
version: systemInfo.version,
dbVersion: systemInfo.database_version,
institution: systemInfo.institution,
institutionGUID: systemInfo.institution_guid,
discipline: systemInfo.discipline,
collection: systemInfo.collection,
collectionGUID: systemInfo.collection_guid,
isaNumber: systemInfo.isa_number,
disciplineType: systemInfo.discipline_type
},
/*
* I don't know if the receiving server handles GET parameters in a
* case-sensitive way. Thus, don't convert keys to lower case, but leave
* them as they were sent in previous versions of Specify 7
*/
false
),
{ errorMode: 'silent' }
).catch(softFail);
return systemInfo;
});

The Client stores its own value of the endpoint value along with caching the url: this is a problem with the application, not a generic browser cache Issue.

I think a fine solution to the problem is to clear the application and browser cache whenever:

  • the user chooses a collections
  • the user logs out

This would also fix a lot of other cache-related Issues as well!

An implementation for clearing the cache when a user chooses/switches collection can theoretically be as simple as modifying the following from:

async () =>
ping('/context/collection/', {
method: 'POST',
body: collectionId!.toString(),
errorMode: 'dismissible',
}).then(() => globalThis.location.replace(nextUrl)),

to:

      async () =>
        ping('/context/collection/', {
          method: 'POST',
          body: collectionId!.toString(),
          errorMode: 'dismissible',
        })
          .then(clearAllCache)
          .then(() => globalThis.location.replace(nextUrl)),

Originally posted by @melton-jason in #6096

@grantfitzsimmons grantfitzsimmons added the 2 - User Interface Issues that are related to the user interface or user experience. label Jan 17, 2025
@grantfitzsimmons grantfitzsimmons modified the milestones: 7.9.11.1, 7.9.11 Jan 22, 2025
@CarolineDenis CarolineDenis self-assigned this Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 - User Interface Issues that are related to the user interface or user experience.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants