Skip to content

Programmatic cache invalidation online #3969

@fabianwohlfart

Description

@fabianwohlfart

Describe the feature

Motivation
I want to let my editor choose when to invalidate the cache after content updates.

Problem
The current implementation sets maxAge, so the file may get's cached by the browser itself.
I have therefor no tool to revoke the browser cache or tell the browser to invalidate the cache.

Caveat
Please correct me if I am wrong or point me to the right direction if I missed something.

Solution
https://github.com/nitrojs/nitro/blob/main/src/runtime/internal/cache.ts#L283

If we would allow custom cacheControl we could customize the behavior as we want.
it could also be a function to be more flexible.

const cacheControl = [];
if (opts.customCacheControl) {
cacheControl.push(opts.customCacheControl)
} else if (opts.swr) {

}

Benefit
I could set customCacheControl to no-store and have always served the cached files until I regenerate them by a webhook call.

Additional information

  • Would you be willing to help implement this feature?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions