Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

327
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!