mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
Added working ETag (304 Not Modified) support based on the final rendered HTML
This commit is contained in:
parent
d11772b681
commit
bc1dd2a7b4
|
|
@ -1,6 +1,8 @@
|
|||
# v1.6.17
|
||||
## mm/dd/2019
|
||||
|
||||
1. [](#new)
|
||||
* Added working ETag (304 Not Modified) support based on the final rendered HTML
|
||||
1. [](#improved)
|
||||
* Safer file handling + customizable null char replacement in `CsvFormatter::decode()`
|
||||
* Change of Behavior: `Inflector::hyphenize` will now automatically trim dashes at beginning and end of a string.
|
||||
|
|
|
|||
|
|
@ -247,9 +247,21 @@ class Grav extends Container
|
|||
$collection = new RequestHandler($this->middleware, $default, $container);
|
||||
|
||||
$response = $collection->handle($this['request']);
|
||||
$body = $response->getBody();
|
||||
|
||||
// Handle ETag and If-None-Match headers.
|
||||
if ($response->getHeaderLine('ETag') === '1') {
|
||||
$etag = md5($body);
|
||||
$response = $response->withHeader('ETag', $etag);
|
||||
|
||||
if ($this['request']->getHeaderLine('If-None-Match') === $etag) {
|
||||
$response = $response->withStatus(304);
|
||||
$body = '';
|
||||
}
|
||||
}
|
||||
|
||||
$this->header($response);
|
||||
echo $response->getBody();
|
||||
echo $body;
|
||||
|
||||
$debugger->render();
|
||||
|
||||
|
|
|
|||
|
|
@ -529,9 +529,9 @@ class Page implements PageInterface
|
|||
$headers['Last-Modified'] = $last_modified_date;
|
||||
}
|
||||
|
||||
// Calculate ETag based on the raw file
|
||||
// Ask Grav to calculate ETag from the final content.
|
||||
if ($this->eTag()) {
|
||||
$headers['ETag'] = '"' . md5($this->raw() . $this->modified()).'"';
|
||||
$headers['ETag'] = '1';
|
||||
}
|
||||
|
||||
// Set Vary: Accept-Encoding header
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user