Skip to content

Commit 2b4c661

Browse files
committed
drop the x- prefix from our custom headers
1 parent 3c4a74f commit 2b4c661

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+208
-213
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ See also the [GitHub releases page](https://github.com/FriendsOfSymfony/FOSHttpC
66
2.0.0 (unreleased)
77
------------------
88

9+
* Change all our custom headers to not use a `X-` prefix to comply with
10+
[RFC 6648](http://tools.ietf.org/html/rfc6648#section-3).
911
* Replace hard coupling on Guzzle HTTP client with HTTP adapter. You now need
1012
to explicitly specify the adapter you want, see [installation instructions]
1113
(http://foshttpcache.readthedocs.org/en/stable/installation.html)

doc/cache-invalidator.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ You can also invalidate the cache based on any headers.
148148
Cache client implementations should fill up the headers to at least have the
149149
default headers always present to simplify the cache configuration rules.
150150

151-
To invalidate on a custom header ``X-My-Header``, you would do::
151+
To invalidate on a custom header ``My-Header``, you would do::
152152

153-
$cacheInvalidator->invalidate(['X-My-Header' => 'my-value'])->flush();
153+
$cacheInvalidator->invalidate(['My-Header' => 'my-value'])->flush();
154154

155155
.. _flush:
156156

doc/includes/custom-ttl.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ the response to remove or reduce the ``s-maxage``. This is not a good solution
1212
however, as you start to duplicate your caching rule definitions.
1313

1414
The solution to this issue provided here is to use a separate, different header
15-
called ``X-Reverse-Proxy-TTL`` that controls the TTL of the caching proxy to
15+
called ``Reverse-Proxy-TTL`` that controls the TTL of the caching proxy to
1616
keep ``s-maxage`` for other proxies. Because this is not a standard feature,
1717
you need to add configuration to your caching proxy.

doc/nginx-configuration.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Refresh
4343
If you want to invalidate cached objects by forcing a :term:`refresh`
4444
you have to use the built-in `proxy_cache_bypass <http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_bypass>`_
4545
directive. This directive defines conditions under which the response will not
46-
be taken from a cache. This library uses a custom HTTP header named ``X-Refresh``,
46+
be taken from a cache. This library uses a custom HTTP header named ``Refresh``,
4747
so add a line like the following to your config:
4848

4949
.. literalinclude:: ../tests/Functional/Fixtures/nginx/fos.conf
@@ -55,9 +55,9 @@ so add a line like the following to your config:
5555
Debugging
5656
~~~~~~~~~
5757

58-
Configure your Nginx to set a custom header (`X-Cache`) that shows whether a
58+
Configure your Nginx to set a custom header (`Cache`) that shows whether a
5959
cache hit or miss occurred:
6060

6161
.. code-block:: none
6262
63-
add_header X-Cache $upstream_cache_status;
63+
add_header Cache $upstream_cache_status;

doc/proxy-clients.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ include that port in the base URL::
102102

103103
The other options for the Varnish client are:
104104

105-
* ``tags_header`` (X-Cache-Tags): Allows you to change the HTTP header used for
105+
* ``tags_header`` (Cache-Tags): Allows you to change the HTTP header used for
106106
tagging. If you change this, make sure to use the correct header name in your
107107
:doc:`caching proxy configuration <proxy-configuration>`;
108108
* ``header_length`` (7500): Control the maximum header size when invalidating
@@ -113,7 +113,7 @@ A full example could look like this::
113113

114114
$options = [
115115
'base_uri' => 'example.com',
116-
'tags_header' => 'X-Custom-Tags-Header',
116+
'tags_header' => 'Custom-Tags-Header',
117117
'header_length' => 4000,
118118
];
119119

@@ -223,7 +223,7 @@ You can specify HTTP headers as the second argument to ``purge()``.
223223
For instance::
224224

225225
$client
226-
->purge('/some/path', ['X-Foo' => 'bar'])
226+
->purge('/some/path', ['Foo' => 'bar'])
227227
->flush()
228228
;
229229

doc/response-tagging.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Before any content is sent out, you need to send the tag header_::
5656
Assume you sent four responses:
5757

5858
+------------+-------------------------+
59-
| Response: | ``X-Cache-Tags`` header:|
59+
| Response: | ``Cache-Tags`` header:|
6060
+============+=========================+
6161
| ``/one`` | ``tag-one`` |
6262
+------------+-------------------------+

doc/symfony-cache-configuration.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ options through the constructor:
191191
* **user_hash_header**: Name of the header the user context hash will be stored
192192
into. Must match the setup for the Vary header in the backend application.
193193

194-
**default**: ``X-User-Context-Hash``
194+
**default**: ``User-Context-Hash``
195195

196196
* **user_hash_uri**: Target URI used in the request for user context hash
197197
generation.
@@ -243,14 +243,14 @@ Custom TTL
243243
.. include:: includes/custom-ttl.rst
244244

245245
The ``CustomTtlSubscriber`` looks at a specific header to determine the TTL,
246-
preferring that over ``s-maxage``. The default header is ``X-Reverse-Proxy-TTL``
246+
preferring that over ``s-maxage``. The default header is ``Reverse-Proxy-TTL``
247247
but you can customize that in the subscriber constructor::
248248

249249
new CustomTtlSubscriber('My-TTL-Header');
250250

251251
The custom header is removed before sending the response to the client.
252252

253-
.. _symfony-cache x-debugging:
253+
.. _symfony-cache debugging:
254254

255255
Debugging
256256
~~~~~~~~~

doc/testing-your-application.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ Enable Assertions
153153
'''''''''''''''''
154154

155155
For the `assertHit` and `assertMiss` assertions to work, you need to add a
156-
:ref:`custom X-Cache header <varnish_debugging>` to responses served
156+
:ref:`custom Cache header <varnish_debugging>` to responses served
157157
by your Varnish.
158158

159159
NginxTest Trait
@@ -225,11 +225,11 @@ CacheAssertions Trait
225225

226226
Provides cache hit/miss assertions to your tests. To enable the these
227227
``assertHit`` and ``assertMiss`` assertions, you need to configure your caching
228-
server to set an `X-Cache` header with the cache status:
228+
server to set an `Cache` header with the cache status:
229229

230230
* :ref:`Varnish <varnish_debugging>`
231231
* :ref:`NGINX <nginx_debugging>`
232-
* :ref:`Symfony HttpCache <symfony-cache x-debugging>`
232+
* :ref:`Symfony HttpCache <symfony-cache debugging>`
233233

234234
Then use the assertions as follows::
235235

doc/user-context.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ Caching on user context works as follows:
4444
3. The :term:`application` receives the hash request. The application knows the
4545
client’s user context (roles, permissions, etc.) and generates a hash based
4646
on that information. The application then returns a response containing that
47-
hash in a custom header (``X-User-Context-Hash``) and with ``Content-Type``
47+
hash in a custom header (``User-Context-Hash``) and with ``Content-Type``
4848
``application/vnd.fos.user-context-hash``.
4949
4. The caching proxy receives the hash response, copies the hash header to the
5050
client’s original request for ``/foo.php`` and restarts that request.
5151
5. If the response to this request should differ per user context, the
52-
application specifies so by setting a ``Vary: X-User-Context-Hash`` header.
52+
application specifies so by setting a ``Vary: User-Context-Hash`` header.
5353
The appropriate user role dependent representation of ``/foo.php`` will
5454
then be returned to the client.
5555

@@ -121,7 +121,7 @@ It is up to you to return the user context hash in response to the hash request
121121
$hash = $hashGenerator->generateHash();
122122

123123
if ('application/vnd.fos.user-context-hash' == strtolower($_SERVER['HTTP_ACCEPT'])) {
124-
header(sprintf('X-User-Context-Hash: %s', $hash));
124+
header(sprintf('User-Context-Hash: %s', $hash));
125125
header('Content-Type: application/vnd.fos.user-context-hash');
126126
exit;
127127
}
@@ -166,7 +166,7 @@ differently depending on whether the user is logged in or not, using the
166166

167167
// /index.php file
168168
header('Cache-Control: max-age=3600');
169-
header('Vary: X-User-Context-Hash');
169+
header('Vary: User-Context-Hash');
170170

171171
$authenticationService = new AuthenticationService();
172172

doc/varnish-configuration.rst

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ To enable support add the following to ``your_varnish.vcl``:
161161
call fos_ban_deliver;
162162
}
163163
164-
This subroutine also sets the ``X-Url`` and ``X-Host`` headers on the cache
164+
This subroutine also sets the ``Url`` and ``Host`` headers on the cache
165165
object. These headers are used by the Varnish `ban lurker`_ that crawls the
166166
content to eventually throw out banned data even when it’s not requested by any
167167
client. Read more on `handling BAN requests`_ in the Varnish documentation (for
@@ -175,10 +175,10 @@ Tagging
175175
Feature: :ref:`cache tagging <tags>`
176176

177177
If you have included ``fos_ban.vcl``, tagging will be automatically enabled
178-
using an ``X-Cache-Tags`` header.
178+
using an ``Cache-Tags`` header.
179179

180180
If you need to use a different tag for the headers than the default
181-
``X-Cache-Tags`` used in ``fos_ban.vcl``, you will have to write your own VCL
181+
``Cache-Tags`` used in ``fos_ban.vcl``, you will have to write your own VCL
182182
code for tag invalidation and change the tagging header
183183
:ref:`configured in the cache invalidator <varnish_custom_tags_header>`. Your custom
184184
VCL will look like this:
@@ -262,13 +262,6 @@ To enable support add the following to ``your_varnish.vcl``:
262262
Your backend application needs to respond to the ``application/vnd.fos.user-context-hash``
263263
request with :ref:`a proper user hash <return context hash>`.
264264

265-
.. note::
266-
267-
We do not use ``X-Original-Url`` here, as the header will be sent to the
268-
backend and the header has semantical meaning for some applications, which
269-
would lead to problems. For example, the Microsoft IIS rewriting module
270-
uses it, and consequently Symfony also looks into it to support IIS.
271-
272265
.. tip::
273266

274267
The provided VCL assumes that you want the context hash to be cached, so we
@@ -352,9 +345,9 @@ The custom header is removed before sending the response to the client.
352345
Debugging
353346
~~~~~~~~~
354347

355-
Configure your Varnish to set a custom header (``X-Cache``) that shows whether a
348+
Configure your Varnish to set a custom header (``Cache``) that shows whether a
356349
cache hit or miss occurred. This header will only be set if your application
357-
sends an ``X-Cache-Debug`` header:
350+
sends an ``Cache-Debug`` header:
358351

359352
Subroutines are provided in ``fos_debug.vcl``.
360353

0 commit comments

Comments
 (0)