mapado/cache-info-bundle

This package is abandoned and no longer maintained. No replacement package was suggested.

Http cache info on top on Symfony Framework Bundle

Installs: 2 301

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 3

Forks: 0

Open Issues: 0

Type:symfony-bundle

v1.0.1 2016-01-12 10:42 UTC

This package is auto-updated.

Last update: 2023-09-15 20:34:02 UTC


README

This bundle adds a simple command to dump information about HTTP Cache in a Symfony project.

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

+------------------------------------------------------------------------------+----------------+---------+
| 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).

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.

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