Skip to content

Opt-out of serverCacheKey #8790

Closed
Closed

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).

Activity

  1. posva commented on Sep 13, 2018

    @posva
    Member

    I think an explicit false rather than undefined makes more sense, but null and undefined also look like an invalid key

  2. urbnjamesmi1 commented on Sep 13, 2018

    @urbnjamesmi1
    Author

    Sounds good. Just looking for a way to conditionally prevent caching.

  3. added 2 commits that reference this issue on Dec 20, 2018
    ab24285
    7ebabe2
  4. yyx990803 commented on Dec 20, 2018

    @yyx990803
    Member

    Closed via ab24285

  5. added 2 commits that reference this issue on Jan 25, 2019
    456b830
    c650c9a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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