Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

329
Visualizações
Slow initial load for API data

Issue:

  • NextJS app takes ~20s to load page with getServerSideProps or getStaticProps
  • After the initial load, everything works fine
  • Issue repeats after site is inactive for about 10min or more
  • This issue does not happen when I npm run build then npm run start from my local machine but does on live site and npm run dev
  • API is currently hosted with Strapi on Heroku (free tier)
  • Exact same thing happens on another site with data hosted on MongoDB (M10 Tier)

Code for page:

const Index = ({ properties, total }) => {
  return (
    <Container>
      <DashboardDrawer />
      <Search />
      <PropertyList properties={properties} />
      <Pagination page={1} total={total} />
    </Container>
  );
};

export default Index;

export const getServerSideProps = async ({ query: { page = 1 } }) => {
  // Calculate start page
  const start = +page === 1 ? 0 : (+page - 1) * PER_PAGE;

  // Fetch total/count
  const totalRes = await fetch(`${API_URL}/properties/count`);
  const total = await totalRes.json();

  // Fetch properties
  const propertyRes = await fetch(
    `${API_URL}/properties?_limit=${PER_PAGE}&_start=${start}`
  );
  const properties = await propertyRes.json();

  return {
    props: { properties, page: +page, total },
  };
};
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda