Skip to content

how does it deal with guest cache? #476

Answered by vinhkhangphung
rebbieboi asked this question in Q&A
Discussion options

You must be logged in to vote

Please take a look at abstract class BaseCacheProfile, it implements function useCacheNameSuffix(Request $request): string from CacheProfile.

public function useCacheNameSuffix(Request $request): string
{
    return Auth::check()
        ? (string) Auth::id()
        : '';
}

As you can see, it returns either User ID or empty string, that is the string use to differ between a logged-in users and guest users. Moreover, you can return as many different string due to as many conditions as you need. If you want both of them to use the same cache, just simply return empty string from the function.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rebbieboi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants