diff --git a/endpoints/gis.weather.php b/endpoints/gis.weather.php index 41a4d7a..1f1fc12 100644 --- a/endpoints/gis.weather.php +++ b/endpoints/gis.weather.php @@ -160,9 +160,15 @@ if ($geocode["status"] == "OK") { $city = $geocode["address"]["city"]; $state = $geocode["address"]["state"]; try { - $epa_url = "https://enviro.epa.gov/enviro/efservice/getEnvirofactsUVHOURLY/CITY/$city/STATE/$state/JSON"; - - $epa_data = json_decode(ApiFetcher::get($epa_url), true); + $epauv = $memcache->get("gis.weather.epauv.$state.$city"); + if ($epauv !== false) { + $epa_data = json_decode($epauv, true); + } else { + $epa_url = "https://enviro.epa.gov/enviro/efservice/getEnvirofactsUVHOURLY/CITY/$city/STATE/$state/JSON"; + $epa_json = file_get_contents($epa_url); + $epa_data = json_decode($epa_json, true); + $memcache->set("gis.weather.epauv.$state.$city", $epa_json, 60 * 60 * 4); + } // Find which returned result is closest to the current date and time $closest = $epa_data[0];