Slow Index.php - Resolved

My website has recently become crazy slow when loading the initial index.php I swear it has something to do with the alerts box as it sits there some times for over 10+ seconds and then loads correctly. I randomly hit a couple of other Saratoga script weather sites that appear to be loading slow as well. Is this potentially a NWS issue?

Any suggestions on how to isolate this?
Thanks
Bonz

Part of the problem is a timeout to api.weather.gov

curl fetching ‘https://api.weather.gov/points/42.2,-71.8333/forecast
Error: Operation timed out after 4000 milliseconds with 0 bytes received
HTTP stats: RC=0 dest=184.50.107.15 port=443 (from sce=162.244.253.208)
Times: dns=0.041 conn=0.317 pxfer=0.888 get=3.111 total=3.999 secs
RC=, bytes=0
That’s good for 4 seconds delay.
Also, you’re not using a cron job for the nws-alerts, so that can add another 3 to 4 seconds of time to the page load… together, they get 7 or 8 seconds of delay.

Also, you’re getting a 404 on the Zone info

so you should change the zone to MAZ012 to have the failover forecast work correctly.

With the advforecast-json script, there may be up to 3 accesses to the api.weather.gov site, and if it’s slow, you get up to 12 seconds of delay due to that. When I ran your homepage with ?force=1&cache=refresh to cause the maximum loading (refreshing all the cache files) the page loaded in 14 seconds and here’s the breakdown for the advforecast-json script

Hope this helps… doing a view-source on the page shows the fetch-times for all the standard support scripts as HTML comments.

Thanks a lot Ken. I changed the zone to MAZ012 so the 404 is gone.
Regarding the Cron. I can certainly create a cron job if this will speed things up. What is the address i should use for the nws-alerts cron in order to force the update?

In nws-alerts-config below i assume i would also need to change the $noCron to true?

GENERAL SETTINGS

$noCron = false; // true=not using cron, update data when cache file expires false=use cron to update data
$updateTime = 600; // IF $noCron=true - time span in seconds to retain cache file before updating
$floodType = true; // true=add prefix ‘Areal’ or ‘River’ to Flood alert title false=no prefix to Flood alert
$noAlertText = ‘No Warnings, Watches, or Advisories’; // Text to display for no alerts.

Lastly, regarding the api.weather.gov timeouts, not sure what I can really do about that other than complain which I doubt will go anywhere :slight_smile:
thanks Ken !!!
John

When running a cron job, make $noCron = false (the double-negative implies a positive… you are running cron).
With $noCron = true, it means you are NOT running cron so the script will fetch data every 10 minutes itself (and those delays will add to the delay loading your page when the cache has to refresh).

I’m hopeful that by August (the next alleged cutover of the forecast.weather.gov site to use api.weather.gov) that the warts will be worked out and connection/download speed for api.weather.gov will be up to standard :slight_smile:

Hi Ken
I’ve always had the $noCron field set to false. With it set like this the cache files below update EVERY TIME I access the webpage. It doesn’t seem to be reading the cache file at all and pulling new data. I did try to put it to true but the page won’t even load so i put it back to false.
The following files update in the cache directory every time I access the webpage and the webpage is seriously impacted as it is waiting for the NWS response before it shows the page.

nws-alertsBoxData.php
nws-alertsIconData.php
nws-alertsMainData.php

Settings are as follows:

GENERAL SETTINGS

$noCron = false; // true=not using cron, update data when cache file expires false=use cron to update data
$updateTime = 600; // IF $noCron=true - time span in seconds to retain cache file before updating
$floodType = true; // true=add prefix ‘Areal’ or ‘River’ to Flood alert title false=no prefix to Flood alert
$noAlertText = ‘No Warnings, Watches, or Advisories’; // Text to display for no alerts.

Thoughts?
Thanks
John

I was able to finally get everything working using $noCron = true
I then went to Cpanel and set up a cron to hit nws-alerts.php and advforcast2.php every 10min and it loads the cache so a user won’t have to wait for the load.

The real test will be to see if it actually works when an alert is issued.