mirror of
https://github.com/ConnectedHumber/Air-Quality-Web
synced 2024-11-26 07:02:59 +00:00
Add cache-control header sending in production mode
This commit is contained in:
parent
26fdc94215
commit
a13f813771
2 changed files with 11 additions and 1 deletions
|
@ -79,7 +79,11 @@ class FetchData implements IAction {
|
||||||
|
|
||||||
// 4: Send response
|
// 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("content-type: application/json");
|
||||||
header("x-time-taken: " . PerfFormatter::format_perf_data($start_time, $start_handle, $start_encode));
|
header("x-time-taken: " . PerfFormatter::format_perf_data($start_time, $start_handle, $start_encode));
|
||||||
echo($response);
|
echo($response);
|
||||||
|
|
|
@ -28,6 +28,12 @@ password = "Define_in_custom_config_file"
|
||||||
# The default action to take if no action is specified
|
# The default action to take if no action is specified
|
||||||
default-action = "fetch-data"
|
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]
|
[data]
|
||||||
# Settings relating to the data returned by the API.
|
# Settings relating to the data returned by the API.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue