-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
Add support for expiration
or maxAge
timestamps
#66
Comments
As a first note, Could you give a real-world example where you need this feature? |
@cyrilletuzi You are totally right, but this could be useful to invalidate data based on age without having to resort to the session storage, which does not last long after the browser/tab closes. It is even being considered, it appears, this will be a workaround until the time comes where it will be supported by default, just like cookies does. One use case for me would be to enforce data expiration on cached results that still needs to be cached but can go stale if left indifinitelly. I can live without it, since I can enforce this in an higher level, but could be nice if the module take care of this by itself. |
Thanks for your feedback. Understood on a theoretical level: it would be for data needing a longer time in storage than just the session duration, but not permanent. But I still don't see where this scenario would happen in practice. Do you have a real world example? |
I was thinking to let the user logged in so if it closes the browser and come back, it doesn' t have to do it again, but to force a clean up in the storage after some time has been passed, which in turn will trigger an unauth state in my app. Maybe this is a little overkill? Haha, sounds very awful when writing it. |
You should set an expiry on the auth key on the server instead, then you can store the key in Localstorage and retrieve it when the browser is closed, but the server will decide if the key is still valid when it’s used. Set a create and expire time stamp on the server.
Note that keeping sessions alive for more than a short period once the browser is closed is a potentially huge security issue.
Best,
:Steve
Stephen R. Smith
Alignsoft
447 Nelson Ave, Burlington, Ontario, Canada, L7S 1N3
P : 905.464.4440
[email protected]
http://www.alignsoft.com
… On Jan 2, 2019, at 7:50 PM, Diosney Sarmiento ***@***.***> wrote:
I was thinking to let the user logged in so if it closes the browser and come back, it doesn' t have to do it again, but to force a clean up in the storage after some time has been passed, which in turn will trigger an unauth state in my app.
Maybe this is a little overkill? Haha, sounds very awful when writing it.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@alignsoft @cyrilletuzi Ok, thanks! |
@diosney Client-side local storages can be modified by the user. So storing an expiration date for authentification in it could be modified by the user to be valid forever. So yes, as it was said, this scenario should be managed on the server. But if there are other scenarios, feel free to share. |
@cyrilletuzi Ok, pretty clear, I understood it all, thanks to both of you and happy new year, I missed that :D |
I think this would be very useful for short-lived caching. Is it something you'd consider adding? |
@Gbuomprisco what would be the use case? |
I'd want to use it as a cache for some of my Ajax requests. They'd be short lived, and get back to loading the actual resource after some time. I know it's not intended as a cache so I am not fussed if you don't intend to add it, and I could easily wrap this to add such functionality, but it'd be pretty handy in cases when you just want to keep a key for a short amount of time before falling back to the source. |
@Gbuomprisco Angular already supports that via I'm using it myself for the same use case you describe. |
My case is a bit more specific, as I'm using Cloud Functions (only work as POST) and Firestore |
It seems that IndexedDb doesn't have a native and automatic mechanism for data expiration, but could be awesome if in the meanwhile a workaround gets added.
What I mean is something like this, setting a
maxAge
or something along with the key and in the next get if the value hasexpired
, well, clean it and return null or something automatically by the module.The text was updated successfully, but these errors were encountered: