firebase-js-sdk
firebase-js-sdk copied to clipboard
FR: provide maxAge option in PersistenceSettings of enableIndexedDbPersistence() to invalidate cache after specified time
Describe your environment
- Operating System version: Ventura 13.0
- Browser version: Chrome 108.0.5359.124
- Firebase SDK version: 9.14.0
- Firebase Product: firestore
Describe the problem
Problem:
- In current project, user data does not change often . If cached data exists, I retrieve it using
getDocFromCache(). Else, I retrieve from server usinggetDoc().
In some cases:
- user can change the data from different device or browser. In such cases, data would not be reflected if force cached is enabled.
Probable Solution:
- introduce maxAge property to enableIndexedDbPersistence to auto delete cached data if it was not updated within defined time (to get the fresh entry from the server)
Relevant Code:
enableIndexedDbPersistence(db, {maxAge: 86400}) // database will remain in local storage for 86400s (1 day) without any update.
.catch((err) => {
console.warn('Failed to persist data: ', err.code, err.message);
});
Hi,
Thanks for filling up this request! The team is going to discuss the feature and will keep you posted.
Internal tracking id: b/269460985
Hi,
This feature is been tracked internally, I will close this github ticket and reporter will be notified in the future when the feature gets implemented.
Hi,
The team decided to keep the ticket open until the feature is implemented or bug is fixed for external visibility.