Skip to content

Commit 7ed7bff

Browse files
Merge branch '3.4' into 4.3
* 3.4: [Yaml] Implement multiline string as scalar block for tagged values [HttpFoundation] Use `Cache-Control: must-revalidate` only if explicit lifetime has been given [FrameworkBundle] Use UserInterface to @return in getUser method [CI] Replace php7.4snapshot with php7.4 in Travis configuration [ExpressionLanguage][Node][BinaryNode] Process division by zero forward caught exception [Validator][ConstraintValidator] Stop passing unnecessary timezone argument to \DateTime add tags before processing them [MonologBridge] Fix debug processor datetime type
2 parents fcafc7c + 723b5ca commit 7ed7bff

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

ResponseHeaderBag.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,13 @@ public function makeDisposition($disposition, $filename, $filenameFallback = '')
267267
*/
268268
protected function computeCacheControlValue()
269269
{
270-
if (!$this->cacheControl && !$this->has('ETag') && !$this->has('Last-Modified') && !$this->has('Expires')) {
271-
return 'no-cache, private';
272-
}
273-
274270
if (!$this->cacheControl) {
271+
if ($this->has('Last-Modified') || $this->has('Expires')) {
272+
return 'private, must-revalidate'; // allows for heuristic expiration (RFC 7234 Section 4.2.2) in the case of "Last-Modified"
273+
}
274+
275275
// conservative by default
276-
return 'private, must-revalidate';
276+
return 'no-cache, private';
277277
}
278278

279279
$header = $this->getCacheControlHeader();

Tests/ResponseHeaderBagTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public function testCacheControlHeader()
5151
$this->assertTrue($bag->hasCacheControlDirective('public'));
5252

5353
$bag = new ResponseHeaderBag(['ETag' => 'abcde']);
54-
$this->assertEquals('private, must-revalidate', $bag->get('Cache-Control'));
54+
$this->assertEquals('no-cache, private', $bag->get('Cache-Control'));
5555
$this->assertTrue($bag->hasCacheControlDirective('private'));
56-
$this->assertTrue($bag->hasCacheControlDirective('must-revalidate'));
56+
$this->assertTrue($bag->hasCacheControlDirective('no-cache'));
5757
$this->assertFalse($bag->hasCacheControlDirective('max-age'));
5858

5959
$bag = new ResponseHeaderBag(['Expires' => 'Wed, 16 Feb 2011 14:17:43 GMT']);

0 commit comments

Comments
 (0)