@@ -166,19 +166,20 @@ default. If you want it respected, add your own logic to ``vcl_fetch``.
166166
167167.. note ::
168168
169- The cache-control headers are described in detail in :rfc: `2616#section-14.9 `.
169+ The cache-control headers are described in detail in :rfc: `2616#section-14.9 `
170+ and further clarified in :rfc: `7234#section-5.2 `.
170171
171172Extra Cache Control Directives
172173""""""""""""""""""""""""""""""
173174
174175You can also set headers that Symfony considers non-standard, some coming from
175- RFCs extending HTTP/1.1. The following options are supported:
176+ RFCs extending :rfc: ` 2616 ` HTTP/1.1. The following options are supported:
176177
177- * ``must_revalidate `` (:rfc: `2616 #section-14.9 `)
178- * ``proxy_revalidate `` (:rfc: `2616 #section-14.9 `)
179- * ``no_transform `` (:rfc: `2616 #section-14.9 `)
180- * ``stale_if_error ``: seconds (:rfc: `5861 `)
181- * ``stale_while_revalidate ``: seconds (:rfc: `5861 `)
178+ * ``must_revalidate `` (:rfc: `7234 #section-5.2.2.1 `)
179+ * ``proxy_revalidate `` (:rfc: `7234 #section-5.2.2.7 `)
180+ * ``no_transform `` (:rfc: `7234 #section-5.2.2.4 `)
181+ * ``stale_if_error ``: seconds (:rfc: `5861#section-4 `)
182+ * ``stale_while_revalidate ``: seconds (:rfc: `5861#section-3 `)
182183
183184The *stale * directives need a parameter specifying the time in seconds how long
184185a cache is allowed to continue serving stale content if needed. The other
@@ -220,16 +221,18 @@ This enables a simplistic ETag calculated as md5 hash of the response body:
220221 .. tip ::
221222
222223 This simplistic ETag handler will not help you to prevent unnecessary work
223- on your webserver , but allows a caching proxy to use the ETag cache
224+ on your web server , but allows a caching proxy to use the ETag cache
224225 validation method to preserve bandwidth. The presence of an ETag tells
225226 clients that they can send a ``If-None-Match `` header with the ETag their
226227 current version of the content has. If the caching proxy still has the same
227228 ETag, it responds with a "304 Not Modified" status.
228229
229- You can get additional performance if you write your own ETag listener that
230- also checks the ETag on requests and decides whether the content of the
231- requested page would still generate the same ETag and abort the request as
232- early as possible to return the "304 Not Modified" status.
230+ You can get additional performance if you write your own ETag handler that
231+ can read an ETag from your content and decide very early in the request
232+ whether the ETag changed or not. It can then terminate the request early
233+ with an empty "304 Not Modified" response. This avoids rendering the whole
234+ page. If the page depends on permissions, make sure to make the ETag differ
235+ based on those permissions (e.g. by appending the :doc: `user context hash </features/user-context >`).
233236
234237``last_modified ``
235238"""""""""""""""""
@@ -255,15 +258,21 @@ This value must be a valid input to ``DateTime``:
255258 ``If-Modified-Since `` requests. Varnish can handle these to serve data
256259 from the cache if it was not invalidated since the client requested it.
257260
258- If you only use these simple configurations to add cache validation
259- information, there is no point in adding both a last modified and ETag
260- header. Usually, you should prefer the ETag method as it is not prone to
261- clock skew issues.
261+ Note that the default system will generate an arbitrary last modified date.
262+ You can get additional performance if you write your own last modified
263+ handler that can compare this date with information about the content of
264+ your page and decide early in the request whether anything changed. It can
265+ then terminate the request early with an empty "304 Not Modified" response.
266+ Using content meta data increases the probability for a 304 response and
267+ avoids rendering the whole page.
262268
263- If your site is under heavy load, your best option is to write either a
264- custom ETag handler or a custom last modified handler that uses the content
265- of the page in a way that can avoid rendering the whole page before
266- deciding whether the cached version is still valid.
269+ See also :rfc: `7232#section-2.2.1 ` for further consideration on how to
270+ generate the last modified date.
271+
272+ .. note ::
273+
274+ You may configure both ETag and last modified on the same response. See
275+ :rfc: `7232#section-2.4 ` for more details.
267276
268277``vary ``
269278""""""""
0 commit comments