Hi, I'm currently facing an issue that **user is not cached ** and when I exit the page then I enter it again the user is fetched again
Even If I switched to another page that also uses the user it's fetched again
User fetch action:
export async function getUser(): Promise<IUser | null> {
const c = cookies();
try {
const res = await fetch(API_URL + "/users/@me", {
method: RequestMethod.Get,
credentials: "include",
headers: {
Cookie: c.toString(),
"Content-Type": "application/json",
},
next: {
tags: ["user"],
},
});
const user = await res.json();
return user;
} catch (error) {
return null;
}
}
Page 1:
import { getUser } from "@/server-actions/auth.actions";
async function Contact() {
const user = await getUser();
return <h1>{JSON.stringify(user)}</h1>;
}
export default Contact;
Page 2:
import { getUser } from "@/server-actions/auth.actions";
import React from "react";
async function Projects() {
const user = await getUser();
return <h1>{JSON.stringify(user)}</h1>;
}
export default Projects;
Representation for what I do:
Home > Projects (User is fetched) ➡ Projects > Home > Contact (User is fetched)
The user should be cached after being fetched at projects
I want to know if this is the normal behaviour or not