Skip to content

Commit c18e65e

Browse files
committed
Caching patch.
Changelog excerpt: - Adjusted the eTaggable method, increasing expiries from 1 month to 6 months to further reduce superfluous requests for static files, and explicitly removing the Cache-Control header due to some implementations setting the Cache-Control header within their own code, prior to calling phpMussel, thus preventing browsers from being able to properly cache phpMussel's static assets (explicitly removing the header should ensure that static assets can be cached as expected).
1 parent 0cb81de commit c18e65e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,7 @@ __*Why "v3.0.0" instead of "v1.0.0?"*__ Prior to phpMussel v3, the "phpMussel Co
137137
[2023.01.27; Maikuolan]: Display proper status message when updating configuration fails.
138138

139139
[2023.02.21; Maikuolan]: Replaced the emojis at the front-end navigation menu with SVGs.
140+
141+
### v3.3.3
142+
143+
[2023.02.28; Maikuolan]: Adjusted the eTaggable method, increasing expiries from 1 month to 6 months to further reduce superfluous requests for static files, and explicitly removing the Cache-Control header due to some implementations setting the Cache-Control header within their own code, prior to calling phpMussel, thus preventing browsers from being able to properly cache phpMussel's static assets (explicitly removing the header should ensure that static assets can be cached as expected).

src/FrontEnd.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: Front-end handler (last modified: 2023.02.20).
11+
* This file: Front-end handler (last modified: 2023.02.28).
1212
*/
1313

1414
namespace phpMussel\FrontEnd;
@@ -2871,6 +2871,7 @@ private function canonical(string $Path): string
28712871
*/
28722872
private function eTaggable(string $Asset, ?callable $Callback = null): void
28732873
{
2874+
header_remove('Cache-Control');
28742875
if (!preg_match('~[^\da-z._]~i', $Asset)) {
28752876
$ThisAsset = $this->getAssetPath($Asset, true);
28762877
if (strlen($ThisAsset) && is_readable($ThisAsset) && ($ThisAssetDel = strrpos($ThisAsset, '.')) !== false) {
@@ -2898,7 +2899,7 @@ private function eTaggable(string $Asset, ?callable $Callback = null): void
28982899
$NewETag = hash('sha256', $AssetData) . '-' . strlen($AssetData);
28992900
header('Last-Modified: ' . gmdate('D, d M Y H:i:s T', filemtime($ThisAsset)));
29002901
header('ETag: "' . $NewETag . '"');
2901-
header('Expires: ' . gmdate('D, d M Y H:i:s T', $this->Loader->Time + 2592000));
2902+
header('Expires: ' . gmdate('D, d M Y H:i:s T', $this->Loader->Time + 15552000));
29022903
if (preg_match('~(?:^|, )(?:"' . $NewETag . '"|' . $NewETag . ')(?:$|, )~', $OldETag)) {
29032904
header('HTTP/1.0 304 Not Modified');
29042905
header('HTTP/1.1 304 Not Modified');

0 commit comments

Comments
 (0)