Skip to content

Add cache expiration time #3340

@ryuapp

Description

@ryuapp

What is the feature you are proposing?

Currently, with cache middleware, once it is cached, it is never updated. I'd like to keep the cache on the server side for short periods of time, but that's currently cumbersome. So, we introduce the concept of expiration time in cache middleware.

Add the duration option and store it in an internal header when the cache matches and check it, as in the example below.

app.use(cache({
    cacheName: 'my-app',
    cacheControl: 'max-age=60',
    duration: 120 // new option
    wait: true,
}))

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions