Skip to content

Commit 63f755a

Browse files
committed
docs: add an example to the header changes
1 parent dd7c025 commit 63f755a

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

user_guide_src/source/changelogs/v4.6.0.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,38 @@ In previous versions, headers set by the ``Response`` class were added to existi
109109
ones - giving no options to change them. That could lead to unexpected behavior when
110110
the same headers were set with mutually exclusive directives.
111111

112+
For example, session will automatically set headers with the ``header()`` function:
113+
114+
.. code-block:: none
115+
116+
Expires: Thu, 19 Nov 1981 08:52:00 GMT
117+
Cache-Control: no-store, no-cache, must-revalidate
118+
Pragma: no-cache
119+
120+
So if we set **Expires** header one more time we will end up with a duplicated header:
121+
122+
.. code-block:: php
123+
124+
$response->removeHeader('Expires'); // has no effect
125+
return $response->setHeader('Expires', 'Sun, 17 Nov 2024 14:17:37 GMT');
126+
127+
Response headers:
128+
129+
.. code-block:: none
130+
131+
Expires: Thu, 19 Nov 1981 08:52:00 GMT
132+
// ...
133+
Expires: Sun, 17 Nov 2024 14:17:37 GMT
134+
135+
Now, we don't know which one will be picked by the browser or which header is the correct one.
136+
With changes in this version our previous header will be override:
137+
138+
.. code-block:: none
139+
140+
Cache-Control: no-store, no-cache, must-revalidate
141+
Pragma: no-cache
142+
Expires: Sun, 17 Nov 2024 14:17:37 GMT
143+
112144
Interface Changes
113145
=================
114146

0 commit comments

Comments
 (0)