Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 654e6d0

Browse filesBrowse files
committed
feature symfony#4728 Add Session Cache Limiting section for NativeSessionStorage (mrclay)
This PR was merged into the 2.3 branch. Discussion ---------- Add Session Cache Limiting section for NativeSessionStorage | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | 2.1+ | Fixed tickets | (none) We're implementing HttpFoundation (by itself) to replace our native session implementation and noticed that NativeSessionStorage [eliminates the global session.cache_limiter value](symfony/symfony@39526df). I understand *why* it must do this, but users should be warned that the default usage prescribed in the manual will cause all pages to be sent with no cache-busting headers. Commits ------- 028038e Add section about setting cache_limiter in NativeSessionStorage
2 parents 5922f50 + 028038e commit 654e6d0
Copy full SHA for 654e6d0

File tree

Expand file treeCollapse file tree

1 file changed

+30
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+30
-0
lines changed

‎components/http_foundation/session_configuration.rst

Copy file name to clipboardExpand all lines: components/http_foundation/session_configuration.rst
+30Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,36 @@ method.
102102

103103
For the sake of clarity, some key options are explained in this documentation.
104104

105+
Session Cache Limiting
106+
~~~~~~~~~~~~~~~~~~~~~~
107+
108+
To avoid users seeing stale data, it's common for session-enabled resources to be
109+
sent with headers that disable caching. For this purpose PHP Sessions has the
110+
``sessions.cache_limiter`` option, which determines which headers, if any, will be
111+
sent with the response when the session in started.
112+
113+
Upon construction,
114+
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\NativeSessionStorage`
115+
sets this global option to ``""`` (send no headers) in case the developer wishes to
116+
use a :class:`Symfony\\Component\\HttpFoundation\\Response` object to manage
117+
response headers.
118+
119+
.. caution::
120+
121+
If you rely on PHP Sessions to manage HTTP caching, you *must* manually set the
122+
``cache_limiter`` option in
123+
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\NativeSessionStorage`
124+
to a non-empty value.
125+
126+
For example, you may set it to PHP's default value during construction:
127+
128+
Example usage::
129+
130+
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
131+
132+
$options['cache_limiter'] = session_cache_limiter();
133+
$storage = new NativeSessionStorage($options);
134+
105135
Session Cookie Lifetime
106136
~~~~~~~~~~~~~~~~~~~~~~~
107137

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.