Skip to content

Commit 67b70ea

Browse files
committed
fix immutable
1 parent 3255e90 commit 67b70ea

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/Cache/NeverChanges.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
public function tokenize(Tokenizer $tokenizer): Tokenizer
1616
{
1717
// there is a component that requires a shorter cache, that wins
18-
if($tokenizer->maxAge < self::YEAR) {
18+
if($tokenizer->maxAge < self::YEAR && $tokenizer->maxAge !== null) {
19+
return $tokenizer;
20+
}
21+
22+
if($tokenizer->noStore) {
1923
return $tokenizer;
2024
}
2125

tests/CacheTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ function render(Tokenizer $tokenizer, AbstractCache ...$directives): string
5050
$tokenizer = new Tokenizer();
5151

5252
$directives[] = new NeverChanges();
53+
expect(render($tokenizer, ...$directives))->toBe("public max-age=604800 immutable");
5354
$directives[] = new Revalidate(RevalidationEnum::AfterError, 300);
5455
expect(render($tokenizer, ...$directives))->toBe("public stale-if-error=300");
5556
$directives[] = new Revalidate(RevalidationEnum::AfterStale, 300);
@@ -71,6 +72,9 @@ function render(Tokenizer $tokenizer, AbstractCache ...$directives): string
7172

7273
$directives[] = new MaxAge(300);
7374
expect(render($tokenizer, ...$directives))->toBe("public max-age=300 no-cache");
75+
76+
$directives[] = new NeverCache();
77+
expect(render($tokenizer, ...$directives))->toBe("private no-store");
7478
});
7579

7680
it('can handle public/private', function () {

0 commit comments

Comments
 (0)