Update docs for Vary: X-Requested-With

This commit is contained in:
Sam Minnee 2018-07-04 15:55:52 +12:00
parent 9c9872ebac
commit 72ce2b422d
2 changed files with 7 additions and 1 deletions

View File

@ -918,6 +918,9 @@ class Director implements TemplateGlobalProvider {
* by checking for a custom header set by jQuery or
* wether 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.
*
* @return boolean
*/
public static function is_ajax() {

View File

@ -209,7 +209,7 @@ when calculating a cache key, usually in addition to the full URL path.
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.
@ -218,3 +218,6 @@ To change the value of the `Vary` header, you can change this value by specifyin
HTTP:
vary: ""
```
Note that if you use `Director::is_ajax()` on cached pages then you should add `X-Requested-With` to the vary
header.