[solved] How to prevent server from caching data ?
Answered
Tan posted this in #help-forum
TanOP
I have made my homepage a SSR. And it fetch data directly from mongodb and renders.
Now whenever I add posts it shows up in the admin panel. Because it is client component. But it doesn't shows up in the home page.
const HomePage = async () => {
await connect();
const posts = await Post.find().sort({ createdAt: -1 }).limit(3);
// Other code
<ul className='grid gap-4'>
{posts.map((p) => (
<Link key={p._id} href={`blogs/${p.slug}`}>
<li className='card-with-shadow bg-white shadow-md border border-gray-300 transition p-4 rounded-md '>
<small className=''>{readableDate(p.createdAt)}</small>
<h2 className='text-xl font-semibold mb-2'>{p.title}</h2>
<p className='mb-4 text-sm'>{p.desc}</p>
</li>
</Link>
))}
</ul>Now whenever I add posts it shows up in the admin panel. Because it is client component. But it doesn't shows up in the home page.
2 Replies
@joulev export const revalidate = 0
TanOP
worked like a magic