Skip to content

Opt-out of serverCacheKey #8790

@urbnjamesmi1

Description

@urbnjamesmi1

What problem does this feature solve?

Being able to decide at runtime if a component should be cached on the server.

For example, if I have a re-usable ImageViewer component that I only want cached in certain use cases.

import { get } from 'lodash-es';
export default {
    name: 'ImageViewer',
    serverCacheKey: (props) => get(props, 'images.0.id'),
    props: {
        images: {
            type: Array,
            required: true
        }
    }
};

It would be preferred to be able to return undefined from the serverCacheKey function and know that the component won't be cached. Currently, it would be cached by its name and would collide with any other uses of the component that also returned undefined.

What does the proposed API look like?

The same API for the existing serverCacheKey that takes the props object, but allow for returning undefined to indicate, to skip looking for the component in the server renderer cache (even if the component has a name).

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