File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -553,6 +553,7 @@ md5 of the content::
553
553
{
554
554
$response = $this->render('MyBundle:Main:index.html.twig');
555
555
$response->setETag(md5($response->getContent()));
556
+ $response->setPublic(); // make sure the response is public/cacheable
556
557
$response->isNotModified($this->getRequest());
557
558
558
559
return $response;
@@ -604,7 +605,14 @@ header value::
604
605
$date = $authorDate > $articleDate ? $authorDate : $articleDate;
605
606
606
607
$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
608
616
609
617
return $response;
610
618
}
@@ -846,6 +854,7 @@ independent of the rest of the page.
846
854
public function indexAction()
847
855
{
848
856
$response = $this->render('MyBundle:MyController:index.html.twig');
857
+ // set the shared max age - the also marks the response as public
849
858
$response->setSharedMaxAge(600);
850
859
851
860
return $response;
You can’t perform that action at this time.
0 commit comments