aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2021-07-02 22:17:33 +0200
committerThomas Lange <code@nerdmind.de>2021-07-02 22:17:33 +0200
commitf025fd3e7be449c06c2e99f77f528f402cd93f72 (patch)
tree1d89d71c716093499caeebf73b9f845a2cac1247
parent299bff3d9e301d954731118c6526f422dc866e0d (diff)
downloadblog-f025fd3e7be449c06c2e99f77f528f402cd93f72.tar.gz
blog-f025fd3e7be449c06c2e99f77f528f402cd93f72.tar.xz
blog-f025fd3e7be449c06c2e99f77f528f402cd93f72.zip
Include category timestamp in ETag response header
This commit adds the timestamp of the last modified category to the HTTP ETag response header. Additionally, the code has been optimized.
-rw-r--r--core/application.php25
1 files changed, 13 insertions, 12 deletions
diff --git a/core/application.php b/core/application.php
index 280a8e7..5d2b1f4 100644
--- a/core/application.php
+++ b/core/application.php
@@ -167,22 +167,23 @@ if(Application::get('MIGRATOR.ENABLED')) {
#===============================================================================
# Check if "304 Not Modified" and ETag header should be sent
#===============================================================================
-if(Application::get('CORE.SEND_304') === TRUE AND !defined('ADMINISTRATION')) {
+if(Application::get('CORE.SEND_304') AND !defined('ADMINISTRATION')) {
#===========================================================================
- # Select edit time from last edited items (page, post, user)
+ # Fetch timestamps of the last modified entities
#===========================================================================
- $execute = '(SELECT time_update FROM %s ORDER BY time_update DESC LIMIT 1) AS %s';
-
- $pageTable = ORM\Repositories\Page::getTableName();
- $postTable = ORM\Repositories\Post::getTableName();
- $userTable = ORM\Repositories\User::getTableName();
-
- $pageSQL = sprintf($execute, $pageTable, $pageTable);
- $postSQL = sprintf($execute, $postTable, $postTable);
- $userSQL = sprintf($execute, $postTable, $postTable);
+ $query = '(SELECT time_update FROM %s ORDER BY time_update DESC LIMIT 1) AS %s';
+
+ foreach([
+ ORM\Repositories\Category::getTableName(),
+ ORM\Repositories\Page::getTableName(),
+ ORM\Repositories\Post::getTableName(),
+ ORM\Repositories\User::getTableName()
+ ] as $table) {
+ $parts[] = sprintf($query, $table, $table);
+ }
- $Statement = $Database->query("SELECT {$pageSQL}, {$postSQL}, {$userSQL}");
+ $Statement = $Database->query('SELECT '.implode(',', $parts));
#===========================================================================
# Define HTTP ETag header identifier