Skip to content

[HttpFoundation] Document all core response http control directives #13500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions components/http_foundation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,18 @@ can be used to set the most commonly used cache information in one method
call::

$response->setCache([
'etag' => 'abcdef',
'last_modified' => new \DateTime(),
'max_age' => 600,
's_maxage' => 600,
'private' => false,
'public' => true,
'immutable' => true,
'must_revalidate' => false,
'no_cache' => false,
'no_store' => false,
'no_transform' => false,
'public' => true,
'private' => false,
'proxy_revalidate' => false,
'max_age' => 600,
's_maxage' => 600,
'immutable' => true,
'last_modified' => new \DateTime(),
'etag' => 'abcdef'
]);

To check if the Response validators (``ETag``, ``Last-Modified``) match a
Expand Down
26 changes: 16 additions & 10 deletions create_framework/http_kernel_httpkernelinterface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,28 @@ The Response class contains methods that let you configure the HTTP cache. One
of the most powerful is ``setCache()`` as it abstracts the most frequently used
caching strategies into a single array::

$date = date_create_from_format('Y-m-d H:i:s', '2005-10-15 10:00:00');

$response->setCache([
'public' => true,
'etag' => 'abcde',
'last_modified' => $date,
'max_age' => 10,
's_maxage' => 10,
'must_revalidate' => false,
'no_cache' => false,
'no_store' => false,
'no_transform' => false,
'public' => true,
'private' => false,
'proxy_revalidate' => false,
'max_age' => 600,
's_maxage' => 600,
'immutable' => true,
'last_modified' => new \DateTime(),
'etag' => 'abcdef'
]);

// it is equivalent to the following code
$response->setPublic();
$response->setMaxAge(600);
$response->setSharedMaxAge(600);
$response->setImmutable();
$response->setLastModified(new \DateTime());
$response->setEtag('abcde');
$response->setLastModified($date);
$response->setMaxAge(10);
$response->setSharedMaxAge(10);

When using the validation model, the ``isNotModified()`` method allows you to
cut on the response time by short-circuiting the response generation as early as
Expand Down
18 changes: 12 additions & 6 deletions http_cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,18 @@ Additionally, most cache-related HTTP headers can be set via the single

// sets cache settings in one call
$response->setCache([
'etag' => $etag,
'last_modified' => $date,
'max_age' => 10,
's_maxage' => 10,
'public' => true,
// 'private' => true,
'must_revalidate' => false,
'no_cache' => false,
'no_store' => false,
'no_transform' => false,
'public' => true,
'private' => false,
'proxy_revalidate' => false,
'max_age' => 600,
's_maxage' => 600,
'immutable' => true,
'last_modified' => new \DateTime(),
'etag' => 'abcdef'
]);

Cache Invalidation
Expand Down