@@ -38,13 +38,15 @@ to implement the validation model: ``ETag`` and ``Last-Modified``.
38
38
Validation with the ``ETag `` Header
39
39
-----------------------------------
40
40
41
- The ``ETag `` header is a string header (called the "entity-tag") that uniquely
42
- identifies one representation of the target resource. It's entirely generated
43
- and set by your application so that you can tell, for example, if the ``/about ``
44
- resource that's stored by the cache is up-to-date with what your application
45
- would return. An ``ETag `` is like a fingerprint and is used to quickly compare
46
- if two different versions of a resource are equivalent. Like fingerprints,
47
- each ``ETag `` must be unique across all representations of the same resource.
41
+ The ``ETag `` ("entity-tag") header is an optional HTTP header whose value is an
42
+ arbitrary string that uniquely identifies one representation of the target
43
+ resource. It's entirely generated and set by your application so that you can
44
+ tell, for example, if the ``/about `` resource that's stored by the cache is
45
+ up-to-date with what your application would return.
46
+
47
+ An ``ETag `` is like a fingerprint and is used to quickly compare if two
48
+ different versions of a resource are equivalent. Like fingerprints, each
49
+ ``ETag `` must be unique across all representations of the same resource.
48
50
49
51
To see a simple implementation, generate the ETag as the md5 of the content::
50
52
@@ -72,6 +74,21 @@ method compares the ``If-None-Match`` header with the ``ETag`` response header.
72
74
If the two match, the method automatically sets the ``Response `` status code
73
75
to 304.
74
76
77
+ .. note ::
78
+
79
+ When using ``mod_deflate `` or ``mod_brotli `` in Apache 2.4, the original
80
+ ``ETag `` value is modified (e.g. if ``ETag `` was ``foo ``, Apache turns it
81
+ into ``foo-gzip `` or ``foo-brotli ``), which breaks the ETag-based validation.
82
+
83
+ Starting from Apache 2.5, you can control this behavior with the
84
+ ``DeflateAlterETag `` and ``BrotliAlterETag `` directives. Alternatively, you
85
+ can use the following Apache configuration to keep both the original ETag
86
+ and the modified one when compressing responses:
87
+
88
+ .. code-block :: apache
89
+
90
+ RequestHeader edit "If-None-Match" '^"((.*)-(gzip|br))"$' '"$1", "$2"'
91
+
75
92
.. note ::
76
93
77
94
The cache sets the ``If-None-Match `` header on the request to the ``ETag ``
0 commit comments