The PHP native cache limiter feature has been disabled as this is now managed by the HeaderBag class directly instead (see below.) The HeaderBag class uses the following rules to define a sensible and convervative default value for the Response 'Cache-Control' header: * If no cache header is defined ('Cache-Control', 'ETag', 'Last-Modified', and 'Expires'), 'Cache-Control' is set to 'no-cache'; * If 'Cache-Control' is empty, its value is set to "private, max-age=0, must-revalidate"; * But if at least one 'Cache-Control' directive is set, and no 'public' or 'private' directives have been explicitely added, Symfony2 adds the 'private' directive automatically (except when 's-maxage' is set.) So, remember to explicitly add the 'public' directive to 'Cache-Control' when you want shared caches to store your application resources: // The Response is private by default $response->setEtag($etag); $response->setLastModified($date); $response->setMaxAge(10); // Change the Response to be public $response->setPublic(); // Set cache settings in one call $response->setCache(array( 'etag' => $etag, 'last_modified' => $date, 'max_age' => 10, 'public' => true, )); |
||
---|---|---|
.. | ||
Symfony/Tests/Component | ||
bootstrap.php |