Overview

Installation

This bundle is available on Packagist. You can install it using Composer. Note that the FOSHttpCache library needs a psr/http-message-implementation and php-http/client-implementation. If your project does not contain one, composer will complain that it did not find psr/http-message-implementation.

To install the bundle together with Symfony HttpClient, run:

$ composer require friendsofsymfony/http-cache-bundle symfony/http-client nyholm/psr7 guzzlehttp/promises

If you want to use something else than Symfony HttpClient, see Packagist for a list of available client implementations.

If you use an old version of Symfony, you must manually register the bundle to your application:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new FOS\HttpCacheBundle\FOSHttpCacheBundle(),
        // ...
    );
}

For most features, you also need to configure a caching proxy.

Requirements

SensioFrameworkExtraBundle

If you want to use this bundle’s annotations, install the SensioFrameworkExtraBundle:

$ composer require sensio/framework-extra-bundle

And , if you don’t use a recent version of Symfony, include it in your project:

 <?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new FOS\HttpCacheBundle\FOSHttpCacheBundle(),
        new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
        // ...
    );

ExpressionLanguage

If you wish to use expressions in your annotations , you also need Symfony’s ExpressionLanguage component. If you’re not using full-stack Symfony 2.4 or later, you need to explicitly add the component:

$ composer require symfony/expression-language

Configuration

Now you can configure the bundle under the fos_http_cache key. The Features section introduces the bundle’s features. The Configuration section lists all configuration options.

Functionality

This table shows where you can find specific functions.

Functionality Annotations Configuration Manually
Set Cache-Control headers (SensioFrameworkExtraBundle) rules (Symfony)
Tag and invalidate @Tag rules cache manager
Invalidate routes @InvalidateRoute invalidators cache manager
Invalidate paths @InvalidatePath invalidators cache manager

License

This bundle is released under the MIT license.

Copyright (c) 2010-2020 Liip, http://www.liip.ch <contact@liip.ch>
                        Driebit, http://www.driebit.nl <info@driebit.nl>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.