Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9147793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:04:44+00:00 2026-06-17T11:04:44+00:00

I have 1-many units in the database Each unit has it’s own update time

  • 0

I have

  1. 1-many units in the database
  2. Each unit has it’s own update time in seconds
  3. Webpage that has dynamic contents
  4. Currently there is auto-refresh (2minutes) embedded see below every time it’s called

function refreshPage(){

minutes = 2;
seconds = 0;  
interval=120000;
getCheckedUnits(); //call to function that checks and updates stuff

}

function timedRefresh(timeoutPeriod) {
    //refreshPage();
    setInterval(refreshPage, timeoutPeriod);
    countdown('countdown');
}

var interval;
var minutes = 2;
var seconds = 0;

function countdown(element) {
    interval = setInterval(function() {
        var el = document.getElementById(element);
        if(seconds == 0) {
            if(minutes == 0) {
                el.innerHTML = "Waiting for refresh";
                clearInterval(interval);
                return;
            } else {
                minutes--;
                seconds = 60;
            }
        }
        if(minutes > 0) {
            var minute_text = minutes + (minutes > 1 ? ' minutes' : ' minute');
        } else {
            var minute_text = '';
        }
        var second_text = seconds > 1 ? 'seconds' : 'second';
        el.innerHTML = 'Page will auto-refresh in: ' + minute_text + ' ' + seconds + ' ' + second_text + ' remaining';
        seconds--;
    }, 1000);
}

What I need to do, it to make it transparent to user and call update based on the need (I have value that is set in the database).

As a solution (in JS-Ajax), I can use the same timer that I have above (set it to 5 seconds) and create an array with objects that store id, last update time and next update time. Then I can update each object only when current time is more that next update time.
Or I can approach this method via cron-job.

I have never done this before and I would like to hear opinions that based on experience. What would be the best option?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:04:45+00:00Added an answer on June 17, 2026 at 11:04 am

    Your scheme of fetching last update times and comparing them before fetching the much larger data is a perfectly valid approach to this problem, but there are others you can consider. In particular, you are trying to achieve is called server push. Using the last-update timestamps can approximate this, but alternative techniques like long polling and (in the future/some browsers) WebSockest are some alternatives.

    Here is a better writeup to a similar question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two database tables that have a many to many relationship: People and
We are building an application that will have clients installed in many sites. Each
We have an old asp.net application that has no unit tests, integration tests, component
Now I have a python project, I write my unit-testing code in many of
I have many PowerPoint presentations that I need to be able to add to
We have many projects with several files inside each. Files can be checked in
I have many flags that I want to store them in an integer, so
I have many text files containing bank transactions in the middle of them. Each
I have many MySQL statements that are running under MySQL 4, but not MySQL
I have 1 unit test method that needs several parameters. I would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.