Skip to content

Commit 0ef0c20

Browse files
committed
Merge branch '3.4' into 4.3
* 3.4: chown and chgrp should also accept int as owner and group Fix RememberMe with null password [Validator] Fix plurals for sr_Latn (Serbian language written in latin script) validation messages [PhpUnitBridge][SymfonyTestsListenerTrait] Remove some unneeded code fix PHP const mapping keys using the inline notation Fix that no-cache requires positive validation with the origin, even for fresh responses
2 parents 24972c6 + 6262649 commit 0ef0c20

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

HttpCache/HttpCache.php

+4
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,10 @@ protected function lookup(Request $request, $catch = false)
353353
return $this->validate($request, $entry, $catch);
354354
}
355355

356+
if ($entry->headers->hasCacheControlDirective('no-cache')) {
357+
return $this->validate($request, $entry, $catch);
358+
}
359+
356360
$this->record($request, 'fresh');
357361

358362
$entry->headers->set('Age', $entry->getAge());

Tests/HttpCache/HttpCacheTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,22 @@ public function testCachesResponsesWithExplicitNoCacheDirective()
443443
$this->assertTrue($this->response->headers->has('Age'));
444444
}
445445

446+
public function testRevalidatesResponsesWithNoCacheDirectiveEvenIfFresh()
447+
{
448+
$this->setNextResponse(200, ['Cache-Control' => 'public, no-cache, max-age=10', 'ETag' => 'some-etag'], 'OK');
449+
$this->request('GET', '/'); // warm the cache
450+
451+
sleep(5);
452+
453+
$this->setNextResponse(304, ['Cache-Control' => 'public, no-cache, max-age=10', 'ETag' => 'some-etag']);
454+
$this->request('GET', '/');
455+
456+
$this->assertHttpKernelIsCalled(); // no-cache -> MUST have revalidated at origin
457+
$this->assertTraceContains('valid');
458+
$this->assertEquals('OK', $this->response->getContent());
459+
$this->assertEquals(0, $this->response->getAge());
460+
}
461+
446462
public function testCachesResponsesWithAnExpirationHeader()
447463
{
448464
$time = \DateTime::createFromFormat('U', time() + 5);

0 commit comments

Comments
 (0)