@Cache

WARNING: You are browsing the documentation for version 2.0 which is not maintained anymore. If some of your projects are still using this version, consider upgrading.
2.0 version
Maintained Unmaintained

@Cache

Usage

The @Cache annotation makes it easy to define HTTP caching:

1
2
3
4
5
6
7
8
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;

/**
 * @Cache(expires="tomorrow")
 */
public function indexAction()
{
}

Attributes

Here is a list of accepted attributes and their HTTP header equivalent:

Annotation Response Method
@Cache(expires="tomorrow") $response->setExpires()
@Cache(smaxage="15") $response->setSharedMaxAge()
@Cache(maxage="15") $response->setMaxAge()

Note

The expires attribute takes any valid date understood by the PHP strtotime() function.


This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.