Execute a method less times possible - PHP
- by serhio
I have a site in multiple languages. I have a method that returns me the today currencies in a array. I display that currencies in a table then.
// --- en/index.php
<?php
include_once "../exchangeRates.php";
$currencies = ReadExchangeRates();
// --- fr/index.php
<?php
include_once "../exchangeRates.php";
$currencies = ReadExchangeRates();
...
// somewhere in the page
<td><?php echo $currencies["eur"]["today"]; ?></td>
So, every time I load, en/ or fr/ or other language, I request the exchange rates from a external site.
Can I optimize this behavior (reading once per day or session)?
maybe to store a global variable and check the update date?