Skip to content

Commit

Permalink
Include modulars for last modification date computation
Browse files Browse the repository at this point in the history
  • Loading branch information
drzraf committed Mar 17, 2022
1 parent 35d4d00 commit 08cc36f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion system/src/Grav/Common/Page/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,15 @@ public function httpHeaders()

// Set Last-Modified header
if ($this->lastModified()) {
$last_modified_date = gmdate('D, d M Y H:i:s', $this->modified()) . ' GMT';
$last_modified = $this->modified();
foreach ($this->children()->modular() as $cpage) {
$modular_mtime = (int)filemtime($cpage->filePath());
if ($modular_mtime > $last_modified) {
$last_modified = $modular_mtime;
}
}

$last_modified_date = gmdate('D, d M Y H:i:s', $last_modified) . ' GMT';
$headers['Last-Modified'] = $last_modified_date;
}

Expand Down

1 comment on commit 08cc36f

@rhukster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the most basic situation with modular pages, but not when you are using collections to build the page content. Also this probably should not be done in the httpHeaders(), better to do it at the page-level. Let me discuss with matias to see what's the best option.

Please sign in to comment.