From 0b308c871d1a757d21e9ec40a6ebe4899693d2e8 Mon Sep 17 00:00:00 2001 From: Daniel Hensby Date: Wed, 13 Jun 2018 14:29:10 +0100 Subject: [PATCH] DOCS Update doc errors --- .../08_Performance/02_HTTP_Cache_Headers.md | 16 ++++++++-------- docs/en/04_Changelogs/4.2.0.md | 10 +++++----- .../Middleware/HTTPCacheControlMiddleware.php | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/en/02_Developer_Guides/08_Performance/02_HTTP_Cache_Headers.md b/docs/en/02_Developer_Guides/08_Performance/02_HTTP_Cache_Headers.md index 946ec67a7..339b17fef 100644 --- a/docs/en/02_Developer_Guides/08_Performance/02_HTTP_Cache_Headers.md +++ b/docs/en/02_Developer_Guides/08_Performance/02_HTTP_Cache_Headers.md @@ -20,11 +20,11 @@ are a great way to learn about HTTP caching. ### Overview In order to support developers in making safe choices around HTTP caching, -we're using a `HTTPCacheControl` class to control if a response +we're using a `HTTPCacheControlMiddleware` class to control if a response should be considered public or private. This is an abstraction on existing -lowlevel APIs like `HTTP::add_cache_headers()` and `SS_HTTPResponse->addHeader()`. +lowlevel APIs like `HTTP::add_cache_headers()` and `HTTPResponse->addHeader()`. -The `HTTPCacheControl` API makes it easier to express your caching preferences +The `HTTPCacheControlMiddleware` API makes it easier to express your caching preferences without running the risk of overriding essential core safety measures. Most commonly, these APIs will prevent HTTP caching of draft content. @@ -96,7 +96,7 @@ The priority order is as followed, sorted in descending order ### Global opt-in for page content -Enable caching for all page content (through `Page_Controller`). +Enable caching for all page content (through `PageController`). ```php disableCache(); - return $this->myPrivateResponse();; + return $this->myPrivateResponse(); } } ``` @@ -173,7 +173,7 @@ class PageController extends ContentController { public function init() { - HTTPCacheControlMiddleware::inst() + HTTPCacheControlMiddleware::singleton() ->enableCache($force=true) // DANGER ZONE ->setMaxAge(60); // 1 minute @@ -199,7 +199,7 @@ headers: The cache age determines the lifetime of your cache, in seconds. It only takes effect if you instruct the cache control -that your response is public in the first place (via `enableCache()` or via modifying the `HTTP.cache_control` defaults). +that your response is cacheable in the first place (via `enableCache()` or via modifying the `HTTP.cache_control` defaults). ```php use SilverStripe\Control\Middleware\HTTPCacheControlMiddleware; @@ -222,7 +222,7 @@ HTTP::register_modification_date('2014-10-10'); ### Vary A `Vary` header tells caches which aspects of the response should be considered -when calculating a cache key, usually in addition to the full URL path. +when calculating a cache key, usually in addition to the full URL. By default, SilverStripe will output a `Vary` header with the following content: ``` diff --git a/docs/en/04_Changelogs/4.2.0.md b/docs/en/04_Changelogs/4.2.0.md index 090975968..807985480 100644 --- a/docs/en/04_Changelogs/4.2.0.md +++ b/docs/en/04_Changelogs/4.2.0.md @@ -209,7 +209,7 @@ SilverStripe\Core\Injector\Injector: In order to support developers in making safe choices around HTTP caching, we've introduced a `HTTPCacheControlMiddleware` class to control if a response should be considered public or private. This is an abstraction on existing -lowlevel APIs like `HTTP::add_cache_headers()` and `SS_HTTPResponse->addHeader()`. +lowlevel APIs like `HTTP::add_cache_headers()` and `HTTPResponse->addHeader()`. This change introduces smaller but necessary changes to HTTP caching headers sent by SilverStripe. If you are relying on HTTP caching in your implementation, @@ -240,7 +240,7 @@ for details on the new API. ##### Global opt-in for page content -Enable caching for all page content (through `Page_Controller`). +Enable caching for all page content (through `PageController`). ```diff enableCache() + ->setMaxAge(60); // 1 minute @@ -286,7 +286,7 @@ class PageController extends ContentController public function myprivateaction($request) { - HTTP::set_cache_age(0); -+ HTTPCacheControl::inst() ++ HTTPCacheControlMiddleware::singleton() + ->disableCache(); return $this->myPrivateResponse(); @@ -323,7 +323,7 @@ class PageController extends ContentController public function init() { - HTTP::set_cache_age(60); -+ HTTPCacheControl::inst() ++ HTTPCacheControlMiddleware::singleton() + ->enableCache($force=true) // DANGER ZONE + ->setMaxAge(60); // 1 minute diff --git a/src/Control/Middleware/HTTPCacheControlMiddleware.php b/src/Control/Middleware/HTTPCacheControlMiddleware.php index 78aa2540a..e849d3d0d 100644 --- a/src/Control/Middleware/HTTPCacheControlMiddleware.php +++ b/src/Control/Middleware/HTTPCacheControlMiddleware.php @@ -769,7 +769,7 @@ class HTTPCacheControlMiddleware implements HTTPMiddleware, Resettable // Errors disable cache (unless some errors are cached intentionally by usercode) if ($response->isError()) { - // Even if publicCache(true) is specfied, errors will be uncachable + // Even if publicCache(true) is specified, errors will be uncacheable $this->disableCache(true); } }