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

Cached image timestamps #51

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

TornadoStorm
Copy link

@TornadoStorm TornadoStorm commented Apr 19, 2024

Adding the ability to access the timestamp when an image was cached would enable the ability to implement custom cache invalidation techniques. For this, I request to add a method to get the timestamp when an image was cached, if it was cached.

My proposal is to simply add a static method: static Future<DateTime?> getCachedDate({required String imageUrl}), which returns the cached date, or null if no cached image is available. Looking at the package's source code, this should be fairly simple as the package already stores timestamps for cached files.

An example of a use case of this would be in an app where a widget displays an image from a Firebase Storage file, where the file could be updated externally at any time. Firebase storage does not currently have a way to notify the client when a file is updated, so a way to solve this would be to store an updatedAt timestamp in the file's metadata, so we just need to fetch the metadata of the file to access its timestamp. With the getCachedDate method, we can then compare our cached image's timestamp with the updatedAt timestamp of the file in the cloud, and invalidate our local cached image if it is outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants