Skip to content

Commit c49560c

Browse files
committed
minor #13500 [HttpFoundation] Document all core response http control directives (osavchenko)
This PR was merged into the master branch. Discussion ---------- [HttpFoundation] Document all core response http control directives Resolve #13496. Commits ------- 30f32d4 Document all core response http control directives
2 parents 56b2067 + 30f32d4 commit c49560c

File tree

3 files changed

+40
-23
lines changed

3 files changed

+40
-23
lines changed

components/http_foundation.rst

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -489,13 +489,18 @@ can be used to set the most commonly used cache information in one method
489489
call::
490490

491491
$response->setCache([
492-
'etag' => 'abcdef',
493-
'last_modified' => new \DateTime(),
494-
'max_age' => 600,
495-
's_maxage' => 600,
496-
'private' => false,
497-
'public' => true,
498-
'immutable' => true,
492+
'must_revalidate' => false,
493+
'no_cache' => false,
494+
'no_store' => false,
495+
'no_transform' => false,
496+
'public' => true,
497+
'private' => false,
498+
'proxy_revalidate' => false,
499+
'max_age' => 600,
500+
's_maxage' => 600,
501+
'immutable' => true,
502+
'last_modified' => new \DateTime(),
503+
'etag' => 'abcdef'
499504
]);
500505

501506
To check if the Response validators (``ETag``, ``Last-Modified``) match a

create_framework/http_kernel_httpkernelinterface.rst

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,22 +117,28 @@ The Response class contains methods that let you configure the HTTP cache. One
117117
of the most powerful is ``setCache()`` as it abstracts the most frequently used
118118
caching strategies into a single array::
119119

120-
$date = date_create_from_format('Y-m-d H:i:s', '2005-10-15 10:00:00');
121-
122120
$response->setCache([
123-
'public' => true,
124-
'etag' => 'abcde',
125-
'last_modified' => $date,
126-
'max_age' => 10,
127-
's_maxage' => 10,
121+
'must_revalidate' => false,
122+
'no_cache' => false,
123+
'no_store' => false,
124+
'no_transform' => false,
125+
'public' => true,
126+
'private' => false,
127+
'proxy_revalidate' => false,
128+
'max_age' => 600,
129+
's_maxage' => 600,
130+
'immutable' => true,
131+
'last_modified' => new \DateTime(),
132+
'etag' => 'abcdef'
128133
]);
129134

130135
// it is equivalent to the following code
131136
$response->setPublic();
137+
$response->setMaxAge(600);
138+
$response->setSharedMaxAge(600);
139+
$response->setImmutable();
140+
$response->setLastModified(new \DateTime());
132141
$response->setEtag('abcde');
133-
$response->setLastModified($date);
134-
$response->setMaxAge(10);
135-
$response->setSharedMaxAge(10);
136142

137143
When using the validation model, the ``isNotModified()`` method allows you to
138144
cut on the response time by short-circuiting the response generation as early as

http_cache.rst

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,18 @@ Additionally, most cache-related HTTP headers can be set via the single
344344

345345
// sets cache settings in one call
346346
$response->setCache([
347-
'etag' => $etag,
348-
'last_modified' => $date,
349-
'max_age' => 10,
350-
's_maxage' => 10,
351-
'public' => true,
352-
// 'private' => true,
347+
'must_revalidate' => false,
348+
'no_cache' => false,
349+
'no_store' => false,
350+
'no_transform' => false,
351+
'public' => true,
352+
'private' => false,
353+
'proxy_revalidate' => false,
354+
'max_age' => 600,
355+
's_maxage' => 600,
356+
'immutable' => true,
357+
'last_modified' => new \DateTime(),
358+
'etag' => 'abcdef'
353359
]);
354360

355361
Cache Invalidation

0 commit comments

Comments
 (0)