Skip to content

Commit

Permalink
docs: add an example to the header changes
Browse files Browse the repository at this point in the history
  • Loading branch information
michalsn committed Dec 25, 2024
1 parent dd7c025 commit 63f755a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions user_guide_src/source/changelogs/v4.6.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,38 @@ In previous versions, headers set by the ``Response`` class were added to existi
ones - giving no options to change them. That could lead to unexpected behavior when
the same headers were set with mutually exclusive directives.

For example, session will automatically set headers with the ``header()`` function:

.. code-block:: none
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
So if we set **Expires** header one more time we will end up with a duplicated header:

.. code-block:: php
$response->removeHeader('Expires'); // has no effect
return $response->setHeader('Expires', 'Sun, 17 Nov 2024 14:17:37 GMT');
Response headers:

.. code-block:: none
Expires: Thu, 19 Nov 1981 08:52:00 GMT
// ...
Expires: Sun, 17 Nov 2024 14:17:37 GMT
Now, we don't know which one will be picked by the browser or which header is the correct one.
With changes in this version our previous header will be override:

.. code-block:: none
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Expires: Sun, 17 Nov 2024 14:17:37 GMT
Interface Changes
=================

Expand Down

0 comments on commit 63f755a

Please sign in to comment.