-
Notifications
You must be signed in to change notification settings - Fork 3
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
Invalidate old cache versions #56
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're touching the cache code anyway, I left some recommendations to improve the structure ^^
src/libs/caching.js
Outdated
@@ -1,5 +1,7 @@ | |||
import { debug, error } from "./logging"; | |||
import { storage } from "webextension-polyfill"; | |||
import Browser, { storage } from "webextension-polyfill"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import Browser, { storage } from "webextension-polyfill"; | |
import { runtime, storage } from "webextension-polyfill"; |
I'm not sure whether importing the whole Browser
object messes with the tree shaking. I think it'd be better to just import the runtime part of it and adjust the code in the rest of the file accordingly.
src/libs/fetchPronouns.js
Outdated
@@ -21,26 +23,24 @@ export async function fetchPronouns(dataID, accountName, type) { | |||
debug(cacheResult); | |||
// Extract the current cache by using object destructuring. | |||
if (accountName in cacheResult.pronounsCache) { | |||
const { value, timestamp } = cacheResult.pronounsCache[accountName]; | |||
const { value, timestamp, version } = cacheResult.pronounsCache[accountName]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point we really shouldn't implement cache logic in this file anymore, otherwise it becomes way to messy once we want to support other pages.
Would be kind if you could extract it into the caching lib.
Currently, whenever we publish a new version old cache entries stay around, potentially breaking things.
To mitigate this issue, check with which version a cache entry was created and refresh if it's not the same.