mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
commit
ae00147de1
@ -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:
|
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.
|
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:
|
SilverStripe\Control\HTTP:
|
||||||
vary: ""
|
vary: ""
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note that if you use `Director::is_ajax()` on cached pages
|
||||||
|
then you should add `X-Requested-With` to the vary header.
|
@ -357,6 +357,9 @@ class PageController extends ContentController
|
|||||||
Note this is different from `Vary: Accept-Encoding`,
|
Note this is different from `Vary: Accept-Encoding`,
|
||||||
which is important for compression (e.g. gzip), and usually added by
|
which is important for compression (e.g. gzip), and usually added by
|
||||||
other layers such as Apache's mod_gzip.
|
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()`.
|
* No longer sets `Last-Modified` date in HTTP response headers in `DataObject::__construct()`.
|
||||||
Uses `ETag` calculation based on response body which is more accurate,
|
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.
|
and resilient against partial and object caching which can produce stale `Last-Modified` values.
|
||||||
|
@ -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
|
* 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.
|
* 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
|
* @param HTTPRequest $request
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
@ -136,7 +136,6 @@ class HTTPCacheControlMiddleware implements HTTPMiddleware, Resettable
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $defaultVary = [
|
private static $defaultVary = [
|
||||||
"X-Requested-With" => true,
|
|
||||||
"X-Forwarded-Protocol" => true,
|
"X-Forwarded-Protocol" => true,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user