Permalink
Browse files

feature #271 Enable ESI caching for blog index (Sergiu Popa, sergiu-p…

…opa)

This PR was merged into the master branch.

Discussion
----------

Enable ESI caching for blog index

We could update the demo app to include by default ESI caching for the blog index and the sidebar.

Commits
-------

dd93ac4 Add current locale in render_esi
0fe72d0 Move Cache Annotation up
536896a Fix base.html.twig to include about
2fc22a9 Rename sidebar to about
54b8733 Change set shared max age with annotation
4d55e53 Remove fragments from config.yml
c4b3816 Remove sidebar action and call Template Controller
e1868eb New line at the end
93d9254 Replace config.php current
09b055f Remove time and add config comments
5d93dea Enable ESI caching for blog index
  • Loading branch information...
2 parents e064efe + dd93ac4 commit 895c518f1cbdab480ca6692c240bbc8aaac24f77 @javiereguiluz javiereguiluz committed Dec 16, 2015
@@ -35,7 +35,7 @@
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="{{ path('homepage') }}">
- Symfony Demo
+ Symfony Demo <!-- ESI TIME: {{ "now"|date('H:i:s') }} -->
</a>
<button type="button" class="navbar-toggle"
@@ -105,16 +105,11 @@
<div id="sidebar" class="col-sm-3">
{% block sidebar %}
- <div class="section about">
- <div class="well well-lg">
- <p>
- {{ 'help.app_description'|trans|raw }}
- </p>
- <p>
- {{ 'help.more_information'|trans|raw }}
- </p>
- </div>
- </div>
+ {{ render_esi(controller('FrameworkBundle:Template:template', {
+ 'template': 'blog/about.html.twig',
+ 'sharedAge': 600,
+ '_locale': app.request.locale
+ })) }}
{% endblock %}
</div>
</div>
@@ -0,0 +1,11 @@
+<div class="section about">
+ <div class="well well-lg">
+ <p>
+ {{ 'help.app_description'|trans|raw }}
+ </p>
+ <p>
+ {{ 'help.more_information'|trans|raw }}
+ </p>
+ <!-- ESI TIME: {{ "now"|date('H:i:s') }} -->
+ </div>
+</div>
@@ -26,7 +26,9 @@ framework:
# See http://symfony.com/doc/current/reference/configuration/framework.html#ide
ide: sublime
- # esi: ~
+ # ESI enabled for blog index and sidebar
+ # http://symfony.com/doc/current/book/http_cache.html#edge-side-includes
+ esi: { enabled: true }
translator: { fallback: "%locale%" }
secret: "%secret%"
router:
@@ -14,6 +14,7 @@
use AppBundle\Entity\Comment;
use AppBundle\Entity\Post;
use AppBundle\Form\CommentType;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
@@ -35,6 +36,7 @@ class BlogController extends Controller
/**
* @Route("/", name="blog_index", defaults={"page" = 1})
* @Route("/page/{page}", name="blog_index_paginated", requirements={"page" : "\d+"})
+ * @Cache(smaxage="10")
*/
public function indexAction($page)
{
View
@@ -33,7 +33,7 @@
// If you use HTTP Cache to improve application performance, uncomment the following lines:
// See http://symfony.com/doc/current/book/http_cache.html#symfony-reverse-proxy
//
-// $kernel = new AppCache($kernel);
+$kernel = new AppCache($kernel);
// If you use HTTP Cache and your application relies on the _method request parameter
// to get the intended HTTP method, uncomment this line.

0 comments on commit 895c518

Please sign in to comment.