cache.rst 834B

1234567891011121314151617181920212223242526272829303132333435
  1. @Cache
  2. ======
  3. Usage
  4. -----
  5. The ``@Cache`` annotation makes it easy to define HTTP caching::
  6. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
  7. /**
  8. * @Cache(expires="tomorrow")
  9. */
  10. public function indexAction()
  11. {
  12. }
  13. Attributes
  14. ----------
  15. Here is a list of accepted attributes and their HTTP header equivalent:
  16. ============================== ===============
  17. Annotation Response Method
  18. ============================== ===============
  19. ``@Cache(expires="tomorrow")`` ``$response->setExpires()``
  20. ``@Cache(smaxage="15")`` ``$response->setSharedMaxAge()``
  21. ``@Cache(maxage="15")`` ``$response->setMaxAge()``
  22. ============================== ===============
  23. .. note::
  24. The ``expires`` attribute takes any valid date understood by the PHP
  25. ``strtotime()`` function.