Skip to the content
Documentation

HttpCache: comparison of v.1 vs v.2

No ratings yet

Versions Compared

Old Version 1

changes.mady.by.user Ricardo Correia

Saved on May 02, 2013

compared with

New Version 2

changes.mady.by.user Ricardo Correia

Saved on May 23, 2013

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Excerpt Include

Exponential Documentation

Exponential Documentation

Content Cache

 

Exponential uses Symfony HttpCache to manage content cache, with both expiration and validation model. Hence an ETag is computed for every content/version and sent in the Http response. It is also possible to use expiration model to get lightning fast responses.

An additional X-Location-Id header is added in the response for identification (see cache purge document).

Configuration

Code Block
exponential:
    system:
        my_siteaccess:
            content:
                view_cache: true      # Activates HttpCache for content
                ttl_cache: true       # Activates expiration based HttpCache for content (very fast)
                default_ttl: 60       # Number of seconds an Http response is valid in cache (if ttl_cache is true)

Making your controller content cache aware

Sometimes you need that your controller's cache expires in the same time than a specific content (i.e. ESI sub-requests with render twig helper, for a menu for instance). To be able to do that, you just need to add X-Location-Id header to the response object:

Code Block
language php
use Symfony\Component\HttpFoundation\Response;

// In a controller
// "Connects" the response to location #123 and sets a max age (TTL) of 1 hour.
$response = new Response();
$response->headers->set( 'X-Location-Id', 123 );
$response->setSharedMaxAge( 3600 );

 

Children Display
all true

Comments

Add a comment

Comments are read by a moderator before they appear.