Merge pull request #8280 from open-sausages/pulls/4/simpler-vary-header

FIX: Remove X-Requested-With from default Vary header
This commit is contained in:
Daniel Hensby 2018-07-24 01:45:07 +01:00 committed by GitHub
commit ae00147de1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 2 deletions

View File

@ -218,7 +218,7 @@ when calculating a cache key, usually in addition to the full URL.
By default, SilverStripe will output a `Vary` header with the following content:
```
Vary: X-Requested-With, X-Forwarded-Protocol
Vary: X-Forwarded-Protocol
```
To change the value of the `Vary` header, you can change this value by specifying the header in configuration.
@ -227,3 +227,6 @@ To change the value of the `Vary` header, you can change this value by specifyin
SilverStripe\Control\HTTP:
vary: ""
```
Note that if you use `Director::is_ajax()` on cached pages
then you should add `X-Requested-With` to the vary header.

View File

@ -357,6 +357,9 @@ class PageController extends ContentController
Note this is different from `Vary: Accept-Encoding`,
which is important for compression (e.g. gzip), and usually added by
other layers such as Apache's mod_gzip.
* Removed `Vary: X-Requested-With` since it's only applicable when varying
content based on the client context, mostly for returning different XHR responses
as determined through `Director::is_ajax()`.
* No longer sets `Last-Modified` date in HTTP response headers in `DataObject::__construct()`.
Uses `ETag` calculation based on response body which is more accurate,
and resilient against partial and object caching which can produce stale `Last-Modified` values.

View File

@ -993,6 +993,9 @@ class Director implements TemplateGlobalProvider
* Checks if the current HTTP-Request is an "Ajax-Request" by checking for a custom header set by
* jQuery or whether a manually set request-parameter 'ajax' is present.
*
* Note that if you plan to use this to alter your HTTP response on a cached page,
* you should add X-Requested-With to the Vary header.
*
* @param HTTPRequest $request
* @return bool
*/

View File

@ -136,7 +136,6 @@ class HTTPCacheControlMiddleware implements HTTPMiddleware, Resettable
* @var array
*/
private static $defaultVary = [
"X-Requested-With" => true,
"X-Forwarded-Protocol" => true,
];