File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ md5 of the content::
553553
{
554554
$response = $this->render('MyBundle:Main:index.html.twig');
555555
$response->setETag(md5($response->getContent()));
556+
$response->setPublic(); // make sure the response is public/cacheable
556557
$response->isNotModified($this->getRequest());
557558

558559
return $response;
@@ -604,7 +605,14 @@ header value::
604605
$date = $authorDate > $articleDate ? $authorDate : $articleDate;
605606

606607
$response->setLastModified($date);
607-
$response->isNotModified($this->getRequest());
608+
// Set response as public. Otherwise it will be private by default.
609+
$response->setPublic();
610+
611+
if ($response->isNotModified($this->getRequest())) {
612+
return $response;
613+
}
614+
615+
// do more work to populate the response will the full content
608616

609617
return $response;
610618
}
@@ -846,6 +854,7 @@ independent of the rest of the page.
846854
public function indexAction()
847855
{
848856
$response = $this->render('MyBundle:MyController:index.html.twig');
857+
// set the shared max age - the also marks the response as public
849858
$response->setSharedMaxAge(600);
850859
851860
return $response;

0 commit comments

Comments
 (0)