Extension:External Data/Caching data
You can configure External Data to cache retrieved web data or program data, both to speed up retrieval of values and to reduce the load on the system whose data is being accessed.
Configuration
[edit]To set up caching, run the update.php script. It will create the table `ed_url_cache`
.
You should also add a line like the following, to set the expiration time of the cache, in seconds; this example line will cache the data for a week:
$wgExternalDataSources['*']['min cache seconds'] = 7 * 24 * 60 * 60;
. This setting can be overridden for a URL, host, second level domain or server-side program.
By default, if data cannot be retrieved, and a cache table exists, #get_web_data will use the cached value for this data even if the cache has already expired.
To disallow this, add the following to LocalSettings.php: $wgExternalDataSources['*']['always allow stale cache'] = false;
. This setting is also overrideable.
Parser function parameters
[edit]The following parameters can be added to any function (such as #for_external_table) that retrieves web or program data, to further configure caching for a specific call:
|cache seconds=
- an optional parameter that sets the number of seconds that the values from this call should be cached; if it is less than$wgExternalDataSources['the relevant data source']['min cache seconds']
, if there is any, the latter will apply; and if the effective cache expiration time is zero, caching is forbidden.|use stale cache=
- an optional parameter that allows this function to use an expired cache entry if it cannot retrieve the real data. Usage of the stale cache can be forced by$wgExternalDataSources['*']['always allow stale cache'] = true;
.