Skip to content

Instantly share code, notes, and snippets.

@leopro
Last active October 9, 2015 11:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leopro/3500049 to your computer and use it in GitHub Desktop.
Save leopro/3500049 to your computer and use it in GitHub Desktop.
require_once __DIR__.'/../app/AppCache.php';
$kernel = new AppCache($kernel);
<p>cached {{ value }}</p>
{% render 'AcmeMyBundle:My:uncached' with {}, {'standalone': true} %}
<?php
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
class MyController
{
/**
* @Template()
* @Cache(smaxage="600")
*/
public function cachedAction()
{
$value = uniqid();
return array('value' => $value);
}
/**
* @Template()
*/
public function uncachedAction()
{
$value = uniqid();
return array('value' => $value);
}
}
_internal:
resource: "@FrameworkBundle/Resources/config/routing/internal.xml"
prefix: /_internal
cached:
pattern: /cached
defaults: { _controller: AcmeMyBundle:My:cached }
<p>uncached {{ value }}</p>
@cordoval
Copy link

nice @leonardo-proietti but

question:

{% render 'AcmeMyBundle:My:uncached' with {}, {'standalone': true} %}

what does the standalone true means? or does?

thanks

@cordoval
Copy link

they should enable gist notifications hmmm

@leopro
Copy link
Author

leopro commented Aug 29, 2012

"By setting standalone to true, you tell Symfony2 that the action should be rendered as an ESI tag."
http://symfony.com/doc/current/book/http_cache.html#using-edge-side-includes

@cbeyer
Copy link

cbeyer commented Sep 7, 2012

Have you found a solution ?

@leopro
Copy link
Author

leopro commented Sep 9, 2012

A solution for what?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment