From 019fdd65e9dc61bc35b1099e450ec12e4dcd1e21 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 16 Jun 2015 09:58:56 -0600 Subject: [PATCH] added toggles to enable/disable `last_modified` and `etag` headers --- system/config/system.yaml | 2 ++ system/src/Grav/Common/Grav.php | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/system/config/system.yaml b/system/config/system.yaml index 98e183b1a..e438e6b4a 100644 --- a/system/config/system.yaml +++ b/system/config/system.yaml @@ -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 diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php index 710984aca..0c8b5348e 100644 --- a/system/src/Grav/Common/Grav.php +++ b/system/src/Grav/Common/Grav.php @@ -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')) {