added toggles to enable/disable last_modified and etag headers

This commit is contained in:
Andy Miller
2015-06-16 09:58:56 -06:00
parent fa432cd32f
commit 019fdd65e9
2 changed files with 9 additions and 3 deletions

View File

@@ -32,6 +32,8 @@ pages:
'<': 'lt'
types: 'txt|xml|html|json|rss|atom' # Pipe separated list of valid page types
expires: 0 # Page expires time in seconds (604800 seconds = 7 days)
last_modified: true # Set the last modified header
etag: true # Set the expires header tag
cache:
enabled: true # Set to true to enable caching

View File

@@ -312,11 +312,15 @@ class Grav extends Container
}
// Set the last modified time
$last_modified_date = gmdate('D, d M Y H:i:s', $page->modified()) . ' GMT';
header('Last-Modified: ' . $last_modified_date);
if ($this['config']->get('system.pages.last_modified')) {
$last_modified_date = gmdate('D, d M Y H:i:s', $page->modified()) . ' GMT';
header('Last-Modified: ' . $last_modified_date);
}
// Calculate a Hash based on the raw file
header('ETag: ' . md5($page->raw().$page->modified()));
if ($this['config']->get('system.pages.etag')) {
header('ETag: ' . md5($page->raw() . $page->modified()));
}
// Set debugger data in headers
if (!($extension === null || $extension == 'html')) {