nicolasazrak / caddy-cache

Caching middleware for caddy
Mozilla Public License 2.0
109 stars 30 forks source link

Get freshness read file #20

Open fellou89 opened 6 years ago

fellou89 commented 6 years ago

GetFreshness exported function to check if file has expired Read function to get responses stored in cache

nicolasazrak commented 6 years ago

@fellou89 Thanks for your PR but I think I don't understand the porpoise of this change:

fellou89 commented 6 years ago

I'm working on an authentication module that validates a client access token and a refresh access token. It needs to cache the authenticated identity that comes back from the auth endpoint. That's where the Read method is used, getting the identity response stored in the cache.

I added the freshness check to cut some time out of the auth process. If an access token cache entry is no longer fresh (has gone past the configured max-age), then I want to return a 401 immediately, without having to incur the additional time it takes to validate the (expired) token on the auth endpoint.

nicolasazrak commented 6 years ago

I don't think this is a good change, it doesn't add a new feature to the plugin nor it fixes a bug. You can develop your plugin without this changes. Instead of using the read method you can use the one from the storage. And with the status of the entry, you always use response == nil.