DEV Community

Cover image for Fixing the Render Free Tier Sleep Issue for Strapi CMS
shubham paul
shubham paul

Posted on

Fixing the Render Free Tier Sleep Issue for Strapi CMS

I am working on a project where the backend is deployed on Render, using Strapi CMS. One challenge with the Render free tier is that the server goes to sleep after 15 minutes of inactivity. This causes delays when developing the frontend, as the data takes too long to load initially, slowing down my development process.

To address this, I thought of a solution: pinging the server every 10 minutes to prevent it from going to sleep. This way, the response times will remain optimal. I wrote a basic JavaScript program to achieve this.
Let's see the code

import axios from "axios";
let i = 1;
async function apiCronJob(){
    try{
            const data = await axios.get("your server endpoitn");
            if(data){
                console.log("request number is: ",i)
            }
            i++;
    }
    catch(e){
            console.log(e)
    }
}


setInterval(apiCronJob,600000);

Enter fullscreen mode Exit fullscreen mode

You can run this code in your computer are make a cron job or worker that will run code.

Comment down your solutions

Top comments (0)