8000 Updated Cookies & Caching section · symfony/symfony-docs@805a548 · GitHub
[go: up one dir, main page]

Skip to content

Commit 805a548

Browse files
lukey78xabbuh
authored andcommitted
Updated Cookies & Caching section
1 parent a8d4cea commit 805a548

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

cookbook/cache/varnish.rst

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,44 @@ session cookie, if there is one, and get rid of all other cookies so that pages
7575
are cached if there is no active session. Unless you changed the default
7676
configuration of PHP, your session cookie has the name ``PHPSESSID``:
7777

78-
.. code-block:: varnish4
78+
.. configuration-block::
7979

80-
sub vcl_recv {
81-
// Remove all cookies except the session ID.
82-
if (req.http.Cookie) {
83-
set req.http.Cookie = ";" + req.http.Cookie;
84-
set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
85-
set req.http.Cookie = regsuball(req.http.Cookie, ";(PHPSESSID)=", "; \1=");
86-
set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
87-
set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");
88-
89-
if (req.http.Cookie == "") {
90-
// If there are no more cookies, remove the header to get page cached.
91-
remove req.http.Cookie;
80+
.. code-block:: varnish4
81+
82+
sub vcl_recv {
83+
// Remove all cookies except the session ID.
84+
if (req.http.Cookie) {
85+
set req.http.Cookie = ";" + req.http.Cookie;
86+
set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
87+
set req.http.Cookie = regsuball(req.http.Cookie, ";(PHPSESSID)=", "; \1=");
88+
set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
89+
set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");
90+
91+
if (req.http.Cookie == "") {
92+
// If there are no more cookies, remove the header to get page cached.
93+
unset req.http.Cookie;
94+
}
9295
}
9396
}
94-
}
97+
98+
.. code-block:: varnish3
99+
100+
sub vcl_recv {
101+
// Remove all cookies except the session ID.
102+
if (req.http.Cookie) {
103+
set req.http.Cookie = ";" + req.http.Cookie;
104+
set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
105+
set req.http.Cookie = regsuball(req.http.Cookie, ";(PHPSESSID)=", "; \1=");
106+
set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
107+
set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");
108+
109+
if (req.http.Cookie == "") {
110+
// If there are no more cookies, remove the header to get page cached.
111+
remove req.http.Cookie;
112+
}
113+
}
114+
}
115+
95116
96117
.. tip::
97118

0 commit comments

Comments
 (0)
0