Add cache-control header sending in production mode

This commit is contained in:
Starbeamrainbowlabs 2019-01-17 14:51:19 +00:00
parent 26fdc94215
commit a13f813771
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
2 changed files with 11 additions and 1 deletions

View File

@ -79,7 +79,11 @@ class FetchData implements IAction {
// 4: Send response
// TODO: Add cache-control headers here in production mode only
// Send a cache-control header, but only in production mode
if($this->settings->get("env.mode") == "production") {
header("cache-control: public, max-age=" . $this->settings->get("cache.max-age"));
}
header("content-type: application/json");
header("x-time-taken: " . PerfFormatter::format_perf_data($start_time, $start_handle, $start_encode));
echo($response);

View File

@ -28,6 +28,12 @@ password = "Define_in_custom_config_file"
# The default action to take if no action is specified
default-action = "fetch-data"
[cache]
# Settings that control how we request that appropriate API responses be cached.
# Note that these only affect select responses that won't change.
# Note also that cache headers are only sent in production mode - see env.mode above
max-age = 2592000 # 30 days
[data]
# Settings relating to the data returned by the API.