2017 © Pedro Peláez
 

symfony-bundle cache-info-bundle

Http cache info on top on Symfony Framework Bundle

image

mapado/cache-info-bundle

Http cache info on top on Symfony Framework Bundle

  • Tuesday, January 12, 2016
  • by jdeniau
  • Repository
  • 2 Watchers
  • 1 Stars
  • 1,837 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 14 % Grown

The README.md

Cache Info Bundle

This bundle adds a simple command to dump information about HTTP Cache in a Symfony project., (*1)

Installation

composer require mapado/cache-info-bundle
// AppKernel.php
    $bundles = array(
        ...
        new Mapado\CacheInfoBundle\MapadoCacheInfoBundle(),
    );

Usage

php app/console mapado:http-cache:list

Dumps a list of informations about your cache settings, (*2)

+------------------------------------------------------------------------------+----------------+---------+
| route + pattern                                                              | private        | ttl     |
+------------------------------------------------------------------------------+----------------+---------+
| my_route                                                                     | public         | 6h      |
| /my/route                                                                    |                |         |
+------------------------------------------------------------------------------+----------------+---------+
| another route                                                                | public         | 1d      |
| /another/route                                                               |                |         |
+------------------------------------------------------------------------------+----------------+---------+
| a private route                                                              | private        | null    |
| /private                                                                     |                |         |
+------------------------------------------------------------------------------+----------------+---------+
| a complex cache route                                                        | public|private | 4h|null |
| /complex                                                                     |                |         |
+------------------------------------------------------------------------------+----------------+---------+

Cache time definition

By default, this command leverage the power of Sensio Framework bundle @Cache annotation. It works also fine with the route cache definition (for the FrameworkBundle:Template:template routes)., (*3)

Complex route cache | Manual cache settings

If you have a complex route cache, or if you manually call $response->setSMaxAge() and $response->setPublic(), you need to use the @CacheMayBe annotation., (*4)

Example

use Mapado\CacheInfoBundle\Annotation\CacheMayBe;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;

class FooController
{
    /**
     * @CacheMayBe(values={@Cache(public=true, smaxage="14400"), @Cache(public=false)})
     */
     public function complexRouteAction()
     {
         $isPublic = // determine if your route is public ...

         $response->setPublic($isPublic);
         if ($isPublic) {
             $response->setSMaxAge(14400);
         }

         return $response;
     }
}

If you don't do that, the route will be marked as private, (*5)

The Versions

12/01 2016

dev-master

9999999-dev

Http cache info on top on Symfony Framework Bundle

  Sources   Download

MIT

The Requires

 

12/01 2016

v1.0.1

1.0.1.0

Http cache info on top on Symfony Framework Bundle

  Sources   Download

MIT

The Requires

 

12/01 2016

v1.0.0

1.0.0.0

Http cache info on top on Symfony Framework Bundle

  Sources   Download

MIT

The Requires