mirror of
https://github.com/getgrav/grav.git
synced 2025-10-26 07:56:07 +01:00
Debugger optimizations
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
# v1.6.0-beta.4
|
||||
## mm/dd/2018
|
||||
|
||||
1. [](#new)
|
||||
* Added `Page::httpResponseCode()` and `Page::httpHeaders()` methods
|
||||
1. [](#improved)
|
||||
* Added apcu autoloader optimization
|
||||
|
||||
|
||||
@@ -482,6 +482,59 @@ class Page implements PageInterface
|
||||
$this->header->{$key} = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function httpResponseCode()
|
||||
{
|
||||
return (int)($this->header()->http_response_code ?? 200);
|
||||
}
|
||||
|
||||
public function httpHeaders()
|
||||
{
|
||||
$headers = [];
|
||||
|
||||
$grav = Grav::instance();
|
||||
$format = $this->templateFormat();
|
||||
$cache_control = $this->cacheControl();
|
||||
$expires = $this->expires();
|
||||
|
||||
// Set Content-Type header
|
||||
$headers['Content-Type'] = Utils::getMimeByExtension($format, 'text/html');
|
||||
|
||||
// Calculate Expires Headers if set to > 0
|
||||
if ($expires > 0) {
|
||||
$expires_date = gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT';
|
||||
if (!$cache_control) {
|
||||
$headers['Cache-Control'] = 'max-age=' . $expires;
|
||||
}
|
||||
$headers['Expires'] = $expires_date;
|
||||
}
|
||||
|
||||
// Set Cache-Control header
|
||||
if ($cache_control) {
|
||||
$headers['Cache-Control'] = strtolower($cache_control);
|
||||
}
|
||||
|
||||
// Set Last-Modified header
|
||||
if ($this->lastModified()) {
|
||||
$last_modified_date = gmdate('D, d M Y H:i:s', $this->modified()) . ' GMT';
|
||||
$headers['Last-Modified'] = $last_modified_date;
|
||||
}
|
||||
|
||||
// Calculate ETag based on the raw file
|
||||
if ($this->eTag()) {
|
||||
$headers['ETag'] = '"' . md5($this->raw() . $this->modified()).'"';
|
||||
}
|
||||
|
||||
// Set Vary: Accept-Encoding header
|
||||
if ($grav['config']->get('system.pages.vary_accept_encoding', false)) {
|
||||
$headers['Vary'] = 'Accept-Encoding';
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the summary.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user