The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Cronjob that updates cached file and takes about 1.5 minutes

Discussion in 'Workarounds and Optimization' started by meteocaldas, Sep 25, 2016.

Tags:
  1. meteocaldas

    meteocaldas Registered

    Joined:
    Sep 25, 2016
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Portugal
    cPanel Access Level:
    Website Owner
    Hi

    In my site and using cpanel, I have several cronjobs that run several php files.
    Each of these php file, creates a cached file (the very first time it runs or there is no cached file)
    and the next times, it updates the existing cached file with new values.

    All cronjobs are working well, but I am having an isuue with one of them.
    This cronjob I am talking about, takes about 1.5 minuts to update the cached file because it gets the new values from different sources and takes about 2.5 seconds for each of the 30 sources.
    It does everything accordingly and the update is perfect but the isuue is...

    If by coincidence, anyone requests that webpage during the update process, then he has to wait a long time (up to 1.5 minutes) before the results are displayed.
    The problem is that the cached file is deleted and then replaced by tha updated cached file, but only after all the values have been collected.
    Of course I get lots of complaints for this borring delay and I have been wondering all possible solutions for this.

    The solution that looks the esasiest one, would be this one:
    - the cached file stays in use while it is beeing updated by means of a temp cache file.
    - after this temp file is complete with all the new updated values, then it replaces the current cached file.

    Is this possible?

    Thanks in advance.
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,830
    Likes Received:
    672
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    You may receive more user-feedback to this type of question via a third-party resource such as StackOverflow, as it seems to relate more to the coding of the script as opposed to a cPanel/WHM feature.

    Thank you.
     
Loading...

Share This Page