1

export async function getServerSideProps({ req, res }) {
    res.setHeader(
        'Cache-Control',
        'public, max-age=1800, stale-while-revalidate=59'
    )
    const resq = await fetch(`${process.env.NEXT_APP_API_URL}/get-project?page=index`);
    const data = await resq.json();

    return {
        props: {
            data: data ? data : "null"
        },
    };
}

I am using getServerSideProps to get myProject data and it's working fine. And Api called is first time but after data get from cache.

But i want data get first time in Cache not an api.

So it is Possible using getServerSideProps ?

Ai9398
  • 33
  • 5
  • Related https://stackoverflow.com/questions/71333002/how-to-enable-cache-for-getserversideprops – DShook May 02 '23 at 20:27
  • @DShook i need data from cache in first time. means when i request the page then get data from cache not an api. Here when i open my app first time then data get from an api. and after i back this page to another page then data get from cache. So i want to like i need to store data in cache and after when i update and delete and edit then only data get from an api otherwise data get from cache. Any soultion ? – Ai9398 May 03 '23 at 04:18

0 Answers0