Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opt-out of serverCacheKey #8790

Closed
urbnjamesmi1 opened this issue Sep 12, 2018 · 3 comments
Closed

Opt-out of serverCacheKey #8790

urbnjamesmi1 opened this issue Sep 12, 2018 · 3 comments

Comments

@urbnjamesmi1
Copy link

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

@posva
Copy link
Member

posva commented Sep 13, 2018

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

@urbnjamesmi1
Copy link
Author

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

@yyx990803 yyx990803 added this to Todo in 2.6 via automation Dec 6, 2018
@yyx990803 yyx990803 moved this from Todo to In progress in 2.6 Dec 20, 2018
yyx990803 added a commit that referenced this issue Dec 20, 2018
@yyx990803
Copy link
Member

Closed via ab24285

2.6 automation moved this from In progress to Done Dec 20, 2018
f2009 pushed a commit to f2009/vue that referenced this issue Jan 25, 2019
f2009 pushed a commit to f2009/vue that referenced this issue Jan 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
2.6
  
Done
Development

No branches or pull requests

3 participants