core/MAINTAINERS.txt | 8 +- core/composer.json | 2 +- core/core.services.yml | 6 +- .../dynamic_page_cache.info.yml} | 2 +- .../dynamic_page_cache.module} | 10 +- .../dynamic_page_cache.services.yml} | 26 ++--- .../DynamicPageCacheSubscriber.php} | 102 ++++++++--------- .../RequestPolicy/DefaultRequestPolicy.php | 8 +- .../PageCache/ResponsePolicy/DenyAdminRoutes.php | 4 +- .../src/Tests/DynamicPageCacheIntegrationTest.php} | 123 +++++++++++---------- .../dynamic_page_cache_test.info.yml} | 4 +- .../dynamic_page_cache_test.routing.yml} | 60 +++++----- .../src/DynamicPageCacheTestController.php} | 8 +- core/modules/page_cache/page_cache.module | 2 +- .../system/src/EventSubscriber/ConfigCacheTag.php | 2 +- .../system/src/Tests/Session/SessionTest.php | 8 +- core/modules/system/system.module | 2 +- core/profiles/minimal/minimal.info.yml | 2 +- core/profiles/standard/src/Tests/StandardTest.php | 12 +- core/profiles/standard/standard.info.yml | 2 +- core/profiles/testing/testing.info.yml | 6 +- sites/example.settings.local.php | 6 +- 22 files changed, 205 insertions(+), 200 deletions(-) diff --git a/core/MAINTAINERS.txt b/core/MAINTAINERS.txt index 68e8419..6a94a6b 100644 --- a/core/MAINTAINERS.txt +++ b/core/MAINTAINERS.txt @@ -312,6 +312,10 @@ Database Logging module DateTime module - Matthew Donadio 'mpdonadio' https://www.drupal.org/u/mpdonadio +Dynamic Page Cache module +- Fabian Franz 'Fabianx' https://www.drupal.org/u/fabianx +- Wim Leers 'Wim Leers' https://www.drupal.org/u/wim-leers + Email module - Nils Destoop 'zuuperman' https://www.drupal.org/u/zuuperman @@ -414,10 +418,6 @@ Search module Serialization module - Damian Lee 'damiankloip' https://www.drupal.org/u/damiankloip -Smart Cache module -- Fabian Franz 'Fabianx' https://www.drupal.org/u/fabianx -- Wim Leers 'Wim Leers' https://www.drupal.org/u/wim-leers - Shortcut module - Tobias Stöckler 'tstoeckler' https://www.drupal.org/u/tstoeckler - Jibran Ijaz 'jibran' https://www.drupal.org/u/jibran diff --git a/core/composer.json b/core/composer.json index a36e7ad..7ec0df3 100644 --- a/core/composer.json +++ b/core/composer.json @@ -73,6 +73,7 @@ "drupal/core-uuid": "self.version", "drupal/datetime": "self.version", "drupal/dblog": "self.version", + "drupal/dynamic_page_cache": "self.version", "drupal/editor": "self.version", "drupal/entity_reference": "self.version", "drupal/field": "self.version", @@ -105,7 +106,6 @@ "drupal/seven": "self.version", "drupal/shortcut": "self.version", "drupal/simpletest": "self.version", - "drupal/smart_cache": "self.version", "drupal/standard": "self.version", "drupal/stark": "self.version", "drupal/statistics": "self.version", diff --git a/core/core.services.yml b/core/core.services.yml index a47743f..090d8f3 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -250,20 +250,20 @@ services: class: Drupal\Core\PageCache\ResponsePolicy\KillSwitch tags: - { name: page_cache_response_policy } - - { name: smart_cache_response_policy } + - { name: dynamic_page_cache_response_policy } page_cache_no_cache_routes: class: Drupal\Core\PageCache\ResponsePolicy\DenyNoCacheRoutes arguments: ['@current_route_match'] public: false tags: - { name: page_cache_response_policy } - - { name: smart_cache_response_policy } + - { name: dynamic_page_cache_response_policy } page_cache_no_server_error: class: Drupal\Core\PageCache\ResponsePolicy\NoServerError public: false tags: - { name: page_cache_response_policy } - - { name: smart_cache_response_policy } + - { name: dynamic_page_cache_response_policy } config.manager: class: Drupal\Core\Config\ConfigManager arguments: ['@entity.manager', '@config.factory', '@config.typed', '@string_translation', '@config.storage', '@event_dispatcher'] diff --git a/core/modules/smart_cache/smart_cache.info.yml b/core/modules/dynamic_page_cache/dynamic_page_cache.info.yml similarity index 81% rename from core/modules/smart_cache/smart_cache.info.yml rename to core/modules/dynamic_page_cache/dynamic_page_cache.info.yml index cdac583..b269036 100644 --- a/core/modules/smart_cache/smart_cache.info.yml +++ b/core/modules/dynamic_page_cache/dynamic_page_cache.info.yml @@ -1,4 +1,4 @@ -name: Smart Cache +name: Internal Dynamic Page Cache type: module description: 'Caches pages, minus the personalized parts. Works well for websites of all sizes.' package: Core diff --git a/core/modules/smart_cache/smart_cache.module b/core/modules/dynamic_page_cache/dynamic_page_cache.module similarity index 46% rename from core/modules/smart_cache/smart_cache.module rename to core/modules/dynamic_page_cache/dynamic_page_cache.module index a6ca2c1..dcd224f 100644 --- a/core/modules/smart_cache/smart_cache.module +++ b/core/modules/dynamic_page_cache/dynamic_page_cache.module @@ -10,16 +10,16 @@ /** * Implements hook_help(). */ -function smart_cache_help($route_name, RouteMatchInterface $route_match) { +function dynamic_page_cache_help($route_name, RouteMatchInterface $route_match) { switch ($route_name) { - case 'help.page.smart_cache': + case 'help.page.dynamic_page_cache': $output = '

' . t('About') . '

'; - $output .= '

' . t('The Smart Cache module caches pages for authenticated users in the database, minus the personalized parts. For more information, see the online documentation for the Smart Cache module.', ['!smartcache-documentation' => 'https://www.drupal.org/documentation/modules/smart_cache']) . '

'; + $output .= '

' . t('The Dynamic Page Cache module caches pages for authenticated users in the database, minus the personalized parts. For more information, see the online documentation for the Dynamic Page Cache module.', ['!dynamic_page_cache-documentation' => 'https://www.drupal.org/documentation/modules/dynamic_page_cache']) . '

'; $output .= '

' . t('Uses') . '

'; $output .= '
'; $output .= '
' . t('Speeding up your site') . '
'; - $output .= '
' . t('Pages are stored the first time they are requested if they are safe to cache, and then are reused. Personalized parts are excluded automatically. Depending on your site configuration and the complexity of particular pages, Smart Cache may significantly increase the speed of your site, even for authenticated users.') . '
'; - $output .= '
' . t('The module requires no configuration. Every part of the page contains metadata that allows Smart Cache to figure this out on its own.') . '
'; + $output .= '
' . t('Pages are stored the first time they are requested if they are safe to cache, and then are reused. Personalized parts are excluded automatically. Depending on your site configuration and the complexity of particular pages, Dynamic Page Cache may significantly increase the speed of your site, even for authenticated users.') . '
'; + $output .= '
' . t('The module requires no configuration. Every part of the page contains metadata that allows Dynamic Page Cache to figure this out on its own.') . '
'; $output .= '
'; return $output; diff --git a/core/modules/smart_cache/smart_cache.services.yml b/core/modules/dynamic_page_cache/dynamic_page_cache.services.yml similarity index 30% rename from core/modules/smart_cache/smart_cache.services.yml rename to core/modules/dynamic_page_cache/dynamic_page_cache.services.yml index 1b8ddbe..2419992 100644 --- a/core/modules/smart_cache/smart_cache.services.yml +++ b/core/modules/dynamic_page_cache/dynamic_page_cache.services.yml @@ -1,29 +1,29 @@ services: - cache.smart_cache: + cache.dynamic_page_cache: class: Drupal\Core\Cache\CacheBackendInterface tags: - { name: cache.bin } factory: cache_factory:get - arguments: [smart_cache] - smart_cache_subscriber: - class: Drupal\smart_cache\EventSubscriber\SmartCacheSubscriber - arguments: ['@smart_cache_request_policy', '@smart_cache_response_policy', '@render_cache', '%renderer.config%'] + arguments: [dynamic_page_cache] + dynamic_page_cache_subscriber: + class: Drupal\dynamic_page_cache\EventSubscriber\DynamicPageCacheSubscriber + arguments: ['@dynamic_page_cache_request_policy', '@dynamic_page_cache_response_policy', '@render_cache', '%renderer.config%'] tags: - { name: event_subscriber } # Request & response policies. - smart_cache_request_policy: - class: Drupal\smart_cache\PageCache\RequestPolicy\DefaultRequestPolicy + dynamic_page_cache_request_policy: + class: Drupal\dynamic_page_cache\PageCache\RequestPolicy\DefaultRequestPolicy tags: - - { name: service_collector, tag: smart_cache_request_policy, call: addPolicy} - smart_cache_response_policy: + - { name: service_collector, tag: dynamic_page_cache_request_policy, call: addPolicy} + dynamic_page_cache_response_policy: class: Drupal\Core\PageCache\ChainResponsePolicy tags: - - { name: service_collector, tag: smart_cache_response_policy, call: addPolicy} + - { name: service_collector, tag: dynamic_page_cache_response_policy, call: addPolicy} lazy: true - smart_cache_deny_admin_routes: - class: Drupal\smart_cache\PageCache\ResponsePolicy\DenyAdminRoutes + dynamic_page_cache_deny_admin_routes: + class: Drupal\dynamic_page_cache\PageCache\ResponsePolicy\DenyAdminRoutes arguments: ['@current_route_match'] public: false tags: - - { name: smart_cache_response_policy } + - { name: dynamic_page_cache_response_policy } diff --git a/core/modules/smart_cache/src/EventSubscriber/SmartCacheSubscriber.php b/core/modules/dynamic_page_cache/src/EventSubscriber/DynamicPageCacheSubscriber.php similarity index 70% rename from core/modules/smart_cache/src/EventSubscriber/SmartCacheSubscriber.php rename to core/modules/dynamic_page_cache/src/EventSubscriber/DynamicPageCacheSubscriber.php index fefda2d..757986b 100644 --- a/core/modules/smart_cache/src/EventSubscriber/SmartCacheSubscriber.php +++ b/core/modules/dynamic_page_cache/src/EventSubscriber/DynamicPageCacheSubscriber.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\smart_cache\EventSubscriber\SmartCacheSubscriber. + * Contains \Drupal\dynamic_page_cache\EventSubscriber\DynamicPageacheSubscriber. */ -namespace Drupal\smart_cache\EventSubscriber; +namespace Drupal\dynamic_page_cache\EventSubscriber; use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheableMetadata; @@ -22,31 +22,31 @@ /** * Returns cached responses as early and avoiding as much work as possible. * - * SmartCache is able to cache so much because it exploits cache contexts: the - * cache contexts that are present capture the variations of every component of - * the page. That, combined with the fact that cacheability metadata is bubbled, - * means that the cache contexts at the page level represent the complete set of - * contexts that the page varies by. + * Dynamic Page Cache is able to cache so much because it exploits cache + * contexts: the cache contexts that are present capture the variations of every + * component of the page. That, combined with the fact that cacheability + * metadata is bubbled, means that the cache contexts at the page level + * represent the complete set of contexts that the page varies by. * - * The reason SmartCache is implemented as two event subscribers (a late REQUEST - * subscriber immediately after routing for cache hits, and an early RESPONSE - * subscriber for cache misses) is because many cache contexts can only be - * evaluated after routing. (Examples: 'user', 'user.permissions', 'route' …) - * Consequently, it is impossible to implement SmartCache as a kernel middleware - * that simply caches per URL. + * The reason Dynamic Page Cache is implemented as two event subscribers (a late + * REQUEST subscriber immediately after routing for cache hits, and an early + * RESPONSE subscriber for cache misses) is because many cache contexts can only + * be evaluated after routing. (Examples: 'user', 'user.permissions', 'route' …) + * Consequently, it is impossible to implement Dynamic Page Cache as a kernel + * middleware that simply caches per URL. * * @see \Drupal\Core\Render\MainContent\HtmlRenderer * @see \Drupal\Core\Cache\CacheableResponseInterface */ -class SmartCacheSubscriber implements EventSubscriberInterface { +class DynamicPageCacheSubscriber implements EventSubscriberInterface { /** - * Attribute name of the Smart Cache request policy result. + * Attribute name of the Dynamic Page Cache request policy result. * * @see onRouteMatch() * @see onRespond() */ - const ATTRIBUTE_REQUEST_POLICY_RESULT = '_smart_cache_request_policy_result'; + const ATTRIBUTE_REQUEST_POLICY_RESULT = '_dynamic_page_cache_request_policy_result'; /** * A request policy rule determining the cacheability of a response. @@ -77,11 +77,11 @@ class SmartCacheSubscriber implements EventSubscriberInterface { protected $rendererConfig; /** - * SmartCache's redirect render array. + * Dynamic Page Cache's redirect render array. * * @var array */ - protected $smartCacheRedirectRenderArray = [ + protected $dynamicPageCacheRedirectRenderArray = [ '#cache' => [ 'keys' => ['response'], 'contexts' => [ @@ -94,12 +94,12 @@ class SmartCacheSubscriber implements EventSubscriberInterface { // @see \Drupal\Core\EventSubscriber\AcceptNegotiation406::onViewDetect406() 'request_format', ], - 'bin' => 'smart_cache', + 'bin' => 'dynamic_page_cache', ], ]; /** - * Constructs a new SmartCacheSubscriber object. + * Constructs a new DynamicPageCacheSubscriber object. * * @param \Drupal\Core\PageCache\RequestPolicyInterface $request_policy * A policy rule determining the cacheability of a request. @@ -118,15 +118,15 @@ public function __construct(RequestPolicyInterface $request_policy, ResponsePoli } /** - * Sets a response in case of a SmartCache cache hit. + * Sets a response in case of a Dynamic Page Cache hit. * * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event * The event to process. */ public function onRouteMatch(GetResponseEvent $event) { - // Don't cache the response if the SmartCache request policies are not met. - // Store the result in a request attribute, so that onResponse() does not - // have to redo the request policy check. + // Don't cache the response if the Dynamic Page Cache request policies are + // not met. Store the result in a request attribute, so that onResponse() + // does not have to redo the request policy check. $request = $event->getRequest(); $request_policy_result = $this->requestPolicy->check($request); $request->attributes->set(self::ATTRIBUTE_REQUEST_POLICY_RESULT, $request_policy_result); @@ -135,16 +135,16 @@ public function onRouteMatch(GetResponseEvent $event) { } // Sets the response for the current route, if cached. - $cached = $this->renderCache->get($this->smartCacheRedirectRenderArray); + $cached = $this->renderCache->get($this->dynamicPageCacheRedirectRenderArray); if ($cached) { $response = $this->renderArrayToResponse($cached); - $response->headers->set('X-Drupal-SmartCache', 'HIT'); + $response->headers->set('X-Drupal-Dynamic-Cache', 'HIT'); $event->setResponse($response); } } /** - * Stores a response in case of a SmartCache cache miss, if cacheable. + * Stores a response in case of a Dynamic Page Cache miss, if cacheable. * * @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event * The event to process. @@ -152,34 +152,34 @@ public function onRouteMatch(GetResponseEvent $event) { public function onResponse(FilterResponseEvent $event) { $response = $event->getResponse(); - // SmartCache only works with cacheable responses. It does not work with - // plain Response objects. (SmartCache needs to be able to access and modify - // the cacheability metadata associated with the response.) + // Dynamic Page Cache only works with cacheable responses. It does not work + // with plain Response objects. (Dynamic Page Cache needs to be able to + // access and modify the cacheability metadata associated with the response.) if (!$response instanceof CacheableResponseInterface) { return; } - // There's no work left to be done if this is a SmartCache cache hit. - if ($response->headers->get('X-Drupal-SmartCache') === 'HIT') { + // There's no work left to be done if this is a Dynamic Page Cache hit. + if ($response->headers->get('X-Drupal-Dynamic-Cache') === 'HIT') { return; } // There's no work left to be done if this is an uncacheable response. if (!$this->shouldCacheResponse($response)) { // The response is uncacheable, mark it as such. - $response->headers->set('X-Drupal-SmartCache', 'UNCACHEABLE'); + $response->headers->set('X-Drupal-Dynamic-Cache', 'UNCACHEABLE'); return; } - // Don't cache the response if SmartCache's request subscriber did not fire, - // because that means it is impossible to have a SmartCache cache hit. - // (This can happen when the master request is for example a 403 or 404, in - // which case a subrequest is performed by the router. In that case, it is - // the subrequest's response that is cached by SmartCache, because the - // routing happens in a request subscriber earlier than SmartCache's and - // immediately sets a response, i.e. the one returned by the subrequest, and - // thus causes SmartCache's request subscriber to not fire for the master - // request.) + // Don't cache the response if Dynamic Page Cache's request subscriber did + // not fire, because that means it is impossible to have a Dynamic Page + // Cache hit. (This can happen when the master request is for example a 403 + // or 404, in which case a subrequest is performed by the router. In that + // case, it is the subrequest's response that is cached by Dynamic Page + // Cache, because the routing happens in a request subscriber earlier than + // Dynamic Page Cache's and immediately sets a response, i.e. the one + // returned by the subrequest, and thus causes Dynamic Page Cache's request + // subscriber to not fire for the master request.) // @see \Drupal\Core\Routing\AccessAwareRouter::checkAccess() // @see \Drupal\Core\EventSubscriber\DefaultExceptionHtmlSubscriber::on403() $request = $event->getRequest(); @@ -187,8 +187,8 @@ public function onResponse(FilterResponseEvent $event) { return; } - // Don't cache the response if the SmartCache request & response policies - // are not met. + // Don't cache the response if the Dynamic Page CAche request & response + // policies are not met. // @see onRouteMatch() if ($request->attributes->get(self::ATTRIBUTE_REQUEST_POLICY_RESULT) === RequestPolicyInterface::DENY || $this->responsePolicy->check($response, $request) === ResponsePolicyInterface::DENY) { return; @@ -197,15 +197,15 @@ public function onResponse(FilterResponseEvent $event) { // Embed the response object in a render array so that RenderCache is able // to cache it, handling cache redirection for us. $response_as_render_array = $this->responseToRenderArray($response); - $this->renderCache->set($response_as_render_array, $this->smartCacheRedirectRenderArray); + $this->renderCache->set($response_as_render_array, $this->dynamicPageCacheRedirectRenderArray); // The response was generated, mark the response as a cache miss. The next // time, it will be a cache hit. - $response->headers->set('X-Drupal-SmartCache', 'MISS'); + $response->headers->set('X-Drupal-Dynamic-Cache', 'MISS'); } /** - * Whether the given response should be cached by SmartCache. + * Whether the given response should be cached by Dynamic Page Cache. * * We consider any response that has cacheability metadata meeting the auto- * placeholdering conditions to be uncacheable. Because those conditions @@ -259,7 +259,7 @@ protected function shouldCacheResponse(CacheableResponseInterface $response) { * @todo Refactor/remove once https://www.drupal.org/node/2551419 lands. */ protected function responseToRenderArray(CacheableResponseInterface $response) { - $response_as_render_array = $this->smartCacheRedirectRenderArray + [ + $response_as_render_array = $this->dynamicPageCacheRedirectRenderArray + [ // The data we actually care about. '#response' => $response, // Tell RenderCache to cache the #response property: the data we actually @@ -302,10 +302,10 @@ public static function getSubscribedEvents() { $events = []; // Run after AuthenticationSubscriber (necessary for the 'user' cache - // context) and MaintenanceModeSubscriber (SmartCache should not be polluted - // by maintenance mode-specific behavior), but before + // context) and MaintenanceModeSubscriber (Dynamic Page Cache should not be + // polluted by maintenance mode-specific behavior), but before // ContentControllerSubscriber (updates _controller, but that is pointless - // when SmartCache runs). + // when Dynamic Page Cache runs). $events[KernelEvents::REQUEST][] = ['onRouteMatch', 27]; // Run before HtmlResponseSubscriber::onRespond(), which has priority 0. diff --git a/core/modules/smart_cache/src/PageCache/RequestPolicy/DefaultRequestPolicy.php b/core/modules/dynamic_page_cache/src/PageCache/RequestPolicy/DefaultRequestPolicy.php similarity index 65% rename from core/modules/smart_cache/src/PageCache/RequestPolicy/DefaultRequestPolicy.php rename to core/modules/dynamic_page_cache/src/PageCache/RequestPolicy/DefaultRequestPolicy.php index 0651b8f..4016221 100644 --- a/core/modules/smart_cache/src/PageCache/RequestPolicy/DefaultRequestPolicy.php +++ b/core/modules/dynamic_page_cache/src/PageCache/RequestPolicy/DefaultRequestPolicy.php @@ -2,16 +2,16 @@ /** * @file - * Contains \Drupal\smart_cache\PageCache\RequestPolicy\DefaultRequestPolicy. + * Contains \Drupal\dynamic_page_cache\PageCache\RequestPolicy\DefaultRequestPolicy. */ -namespace Drupal\smart_cache\PageCache\RequestPolicy; +namespace Drupal\dynamic_page_cache\PageCache\RequestPolicy; use Drupal\Core\PageCache\ChainRequestPolicy; use Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod; /** - * The default SmartCache request policy. + * The default Dynamic Page Cache request policy. * * Delivery of cached pages is denied if either the application is running from * the command line or the request was not initiated with a safe method (GET or @@ -20,7 +20,7 @@ class DefaultRequestPolicy extends ChainRequestPolicy { /** - * Constructs the default SmartCache request policy. + * Constructs the default Dynamic Page Cache request policy. */ public function __construct() { $this->addPolicy(new CommandLineOrUnsafeMethod()); diff --git a/core/modules/smart_cache/src/PageCache/ResponsePolicy/DenyAdminRoutes.php b/core/modules/dynamic_page_cache/src/PageCache/ResponsePolicy/DenyAdminRoutes.php similarity index 89% rename from core/modules/smart_cache/src/PageCache/ResponsePolicy/DenyAdminRoutes.php rename to core/modules/dynamic_page_cache/src/PageCache/ResponsePolicy/DenyAdminRoutes.php index b3458f8..d79b659 100644 --- a/core/modules/smart_cache/src/PageCache/ResponsePolicy/DenyAdminRoutes.php +++ b/core/modules/dynamic_page_cache/src/PageCache/ResponsePolicy/DenyAdminRoutes.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\smart_cache\PageCache\ResponsePolicy\DenyAdminRoutes. + * Contains \Drupal\dynamic_page_cache\PageCache\ResponsePolicy\DenyAdminRoutes. */ -namespace Drupal\smart_cache\PageCache\ResponsePolicy; +namespace Drupal\dynamic_page_cache\PageCache\ResponsePolicy; use Drupal\Core\PageCache\ResponsePolicyInterface; use Drupal\Core\Routing\RouteMatchInterface; diff --git a/core/modules/smart_cache/src/Tests/SmartCacheIntegrationTest.php b/core/modules/dynamic_page_cache/src/Tests/DynamicPageCacheIntegrationTest.php similarity index 29% rename from core/modules/smart_cache/src/Tests/SmartCacheIntegrationTest.php rename to core/modules/dynamic_page_cache/src/Tests/DynamicPageCacheIntegrationTest.php index 9956a08..b7973dd 100644 --- a/core/modules/smart_cache/src/Tests/SmartCacheIntegrationTest.php +++ b/core/modules/dynamic_page_cache/src/Tests/DynamicPageCacheIntegrationTest.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\smart_cache\Tests\SmartCacheIntegrationTest. + * Contains \Drupal\dynamic_page_cache\Tests\DynamicPageCacheIntegrationTest. */ -namespace Drupal\smart_cache\Tests; +namespace Drupal\dynamic_page_cache\Tests; use Drupal\Core\EventSubscriber\MainContentViewSubscriber; use Drupal\Core\Url; @@ -13,18 +13,19 @@ use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait; /** - * Enables the Smart Cache and tests it in various scenarios. + * Enables the Dynamic Page Cache and tests it in various scenarios. * * This does not test the self-healing of the redirect with conditional cache - * contexts, because SmartCache just reuses \Drupal\Core\Render\RenderCache so - * that it doesn't have to implement and test all of that again. It is tested in + * contexts, because Dynamic Page Cache just reuses + * \Drupal\Core\Render\RenderCache so that it doesn't have to implement and test + * all of that again. It is tested in * RendererBubblingTest::testConditionalCacheContextBubblingSelfHealing(). * - * @group smart_cache + * @group dynamic_page_cache * - * @see \Drupal\smart_cache\EventSubscriber\SmartCacheSubscriber + * @see \Drupal\dynamic_page_cache\EventSubscriber\DynamicPageCacheSubscriber */ -class SmartCacheIntegrationTest extends WebTestBase { +class DynamicPageCacheIntegrationTest extends WebTestBase { /** * {@inheritdoc} @@ -34,7 +35,7 @@ class SmartCacheIntegrationTest extends WebTestBase { /** * {@inheritdoc} */ - protected static $modules = ['smart_cache_test']; + protected static $modules = ['dynamic_page_cache_test']; /** * {@inheritdoc} @@ -42,85 +43,89 @@ class SmartCacheIntegrationTest extends WebTestBase { protected function setUp() { parent::setUp(); - // Uninstall the page_cache module; we want to test the SmartCache alone. + // Uninstall the page_cache module; we want to test the Dynamic Page Cache + // alone. \Drupal::service('module_installer')->uninstall(['page_cache']); } /** - * Tests that SmartCache works correctly, and verifies the edge cases. + * Tests that Dynamic Page Cache works correctly, and verifies the edge cases. */ - public function testSmartCache() { - // Controllers returning plain response objects are ignored by SmartCache. - $url = Url::fromUri('route:smart_cache_test.response'); + public function testDynamicPageCache() { + // Controllers returning plain response objects are ignored by Dynamic Page + // Cache. + $url = Url::fromUri('route:dynamic_page_cache_test.response'); $this->drupalGet($url); - $this->assertFalse($this->drupalGetHeader('X-Drupal-SmartCache'), 'Response object returned: SmartCache is ignoring.'); + $this->assertFalse($this->drupalGetHeader('X-Drupal-Dynamic-Cache'), 'Response object returned: Dynamic Page Cache is ignoring.'); // Controllers returning CacheableResponseInterface (cacheable response) - // objects are handled by SmartCache. - $url = Url::fromUri('route:smart_cache_test.cacheable_response'); + // objects are handled by Dynamic Page Cache. + $url = Url::fromUri('route:dynamic_page_cache_test.cacheable_response'); $this->drupalGet($url); - $this->assertEqual('MISS', $this->drupalGetHeader('X-Drupal-SmartCache'), 'Cacheable response object returned: SmartCache is active, SmartCache MISS.'); + $this->assertEqual('MISS', $this->drupalGetHeader('X-Drupal-Dynamic-Cache'), 'Cacheable response object returned: Dynamic Page Cache is active, Dynamic Page Cache MISS.'); $this->drupalGet($url); - $this->assertEqual('HIT', $this->drupalGetHeader('X-Drupal-SmartCache'), 'Cacheable response object returned: SmartCache is active, SmartCache HIT.'); + $this->assertEqual('HIT', $this->drupalGetHeader('X-Drupal-Dynamic-Cache'), 'Cacheable response object returned: Dynamic Page Cache is active, Dynamic Page Cache HIT.'); // Controllers returning render arrays, rendered as HTML responses, are - // handled by SmartCache. - $url = Url::fromUri('route:smart_cache_test.html'); + // handled by Dynamic Page Cache. + $url = Url::fromUri('route:dynamic_page_cache_test.html'); $this->drupalGet($url); - $this->assertEqual('MISS', $this->drupalGetHeader('X-Drupal-SmartCache'), 'Render array returned, rendered as HTML response: SmartCache is active, SmartCache MISS.'); + $this->assertEqual('MISS', $this->drupalGetHeader('X-Drupal-Dynamic-Cache'), 'Render array returned, rendered as HTML response: Dynamic Page Cache is active, Dynamic Page Cache MISS.'); $this->drupalGet($url); - $this->assertEqual('HIT', $this->drupalGetHeader('X-Drupal-SmartCache'), 'Render array returned, rendered as HTML response: SmartCache is active, SmartCache HIT.'); + $this->assertEqual('HIT', $this->drupalGetHeader('X-Drupal-Dynamic-Cache'), 'Render array returned, rendered as HTML response: Dynamic Page Cache is active, Dynamic Page Cache HIT.'); // The above is the simple case, where the render array returned by the // response contains no cache contexts. So let's now test a route/controller // that *does* vary by a cache context whose value we can easily control: it // varies by the 'animal' query argument. foreach (['llama', 'piggy', 'unicorn', 'kitten'] as $animal) { - $url = Url::fromUri('route:smart_cache_test.html.with_cache_contexts', ['query' => ['animal' => $animal]]); + $url = Url::fromUri('route:dynamic_page_cache_test.html.with_cache_contexts', ['query' => ['animal' => $animal]]); $this->drupalGet($url); $this->assertRaw($animal); - $this->assertEqual('MISS', $this->drupalGetHeader('X-Drupal-SmartCache'), 'Render array returned, rendered as HTML response: SmartCache is active, SmartCache MISS.'); + $this->assertEqual('MISS', $this->drupalGetHeader('X-Drupal-Dynamic-Cache'), 'Render array returned, rendered as HTML response: Dynamic Page Cache is active, Dynamic Page Cache MISS.'); $this->drupalGet($url); $this->assertRaw($animal); - $this->assertEqual('HIT', $this->drupalGetHeader('X-Drupal-SmartCache'), 'Render array returned, rendered as HTML response: SmartCache is active, SmartCache HIT.'); + $this->assertEqual('HIT', $this->drupalGetHeader('X-Drupal-Dynamic-Cache'), 'Render array returned, rendered as HTML response: Dynamic Page Cache is active, Dynamic Page Cache HIT.'); - // Finally, let's also verify that the 'smart_cache_test.html' route - // continued to see cache hits if we specify a query argument, because it - // *should* ignore it and continue to provide SmartCache hits. - $url = Url::fromUri('route:smart_cache_test.html', ['query' => ['animal' => 'piglet']]); + // Finally, let's also verify that the 'dynamic_page_cache_test.html' + // route continued to see cache hits if we specify a query argument, + // because it *should* ignore it and continue to provide Dynamic Page + // Cache hits. + $url = Url::fromUri('route:dynamic_page_cache_test.html', ['query' => ['animal' => 'piglet']]); $this->drupalGet($url); - $this->assertEqual('HIT', $this->drupalGetHeader('X-Drupal-SmartCache'), 'Render array returned, rendered as HTML response: SmartCache is active, SmartCache HIT.'); + $this->assertEqual('HIT', $this->drupalGetHeader('X-Drupal-Dynamic-Cache'), 'Render array returned, rendered as HTML response: Dynamic Page Cache is active, Dynamic Page Cache HIT.'); } // Controllers returning render arrays, rendered as anything except a HTML - // response, are ignored by SmartCache (but only because those wrapper - // formats's responses do not implement CacheableResponseInterface). - $this->drupalGet('smart-cache-test/html', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax'))); - $this->assertFalse($this->drupalGetHeader('X-Drupal-SmartCache'), 'Render array returned, rendered as AJAX response: SmartCache is ignoring.'); - $this->drupalGet('smart-cache-test/html', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_dialog'))); - $this->assertFalse($this->drupalGetHeader('X-Drupal-SmartCache'), 'Render array returned, rendered as dialog response: SmartCache is ignoring.'); - $this->drupalGet('smart-cache-test/html', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal'))); - $this->assertFalse($this->drupalGetHeader('X-Drupal-SmartCache'), 'Render array returned, rendered as modal response: SmartCache is ignoring.'); - - // Admin routes are ignored by SmartCache. - $this->drupalGet('smart-cache-test/html/admin'); - $this->assertFalse($this->drupalGetHeader('X-Drupal-SmartCache'), 'Response returned, rendered as HTML response, admin route: SmartCache is ignoring'); - $this->drupalGet('smart-cache-test/response/admin'); - $this->assertFalse($this->drupalGetHeader('X-Drupal-SmartCache'), 'Response returned, plain response, admin route: SmartCache is ignoring'); - $this->drupalGet('smart-cache-test/cacheable-response/admin'); - $this->assertFalse($this->drupalGetHeader('X-Drupal-SmartCache'), 'Response returned, cacheable response, admin route: SmartCache is ignoring'); - - // Max-age = 0 responses are ignored by SmartCache. - $this->drupalGet('smart-cache-test/html/uncacheable/max-age'); - $this->assertEqual('UNCACHEABLE', $this->drupalGetHeader('X-Drupal-SmartCache'), 'Render array returned, rendered as HTML response, but uncacheable: SmartCache is running, but not caching.'); - - // 'user' cache context responses are ignored by SmartCache. - $this->drupalGet('smart-cache-test/html/uncacheable/contexts'); - $this->assertEqual('UNCACHEABLE', $this->drupalGetHeader('X-Drupal-SmartCache'), 'Render array returned, rendered as HTML response, but uncacheable: SmartCache is running, but not caching.'); - - // 'current-temperature' cache tag responses are ignored by SmartCache. - $this->drupalGet('smart-cache-test/html/uncacheable/tags'); - $this->assertEqual('MISS', $this->drupalGetHeader('X-Drupal-SmartCache'), 'By default, Drupal has no auto-placeholdering cache tags.'); + // response, are ignored by Dynamic Page Cache (but only because those + // wrapper formats' responses do not implement CacheableResponseInterface). + $this->drupalGet('dynamic-page-cache-test/html', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax'))); + $this->assertFalse($this->drupalGetHeader('X-Drupal-Dynamic-Cache'), 'Render array returned, rendered as AJAX response: Dynamic Page Cache is ignoring.'); + $this->drupalGet('dynamic-page-cache-test/html', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_dialog'))); + $this->assertFalse($this->drupalGetHeader('X-Drupal-Dynamic-Cache'), 'Render array returned, rendered as dialog response: Dynamic Page Cache is ignoring.'); + $this->drupalGet('dynamic-page-cache-test/html', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal'))); + $this->assertFalse($this->drupalGetHeader('X-Drupal-Dynamic-Cache'), 'Render array returned, rendered as modal response: Dynamic Page Cache is ignoring.'); + + // Admin routes are ignored by Dynamic Page Cache. + $this->drupalGet('dynamic-page-cache-test/html/admin'); + $this->assertFalse($this->drupalGetHeader('X-Drupal-Dynamic-Cache'), 'Response returned, rendered as HTML response, admin route: Dynamic Page Cache is ignoring'); + $this->drupalGet('dynamic-page-cache-test/response/admin'); + $this->assertFalse($this->drupalGetHeader('X-Drupal-Dynamic-Cache'), 'Response returned, plain response, admin route: Dynamic Page Cache is ignoring'); + $this->drupalGet('dynamic-page-cache-test/cacheable-response/admin'); + $this->assertFalse($this->drupalGetHeader('X-Drupal-Dynamic-Cache'), 'Response returned, cacheable response, admin route: Dynamic Page Cache is ignoring'); + + // Max-age = 0 responses are ignored by SmDynamic Page Cache artCache. + $this->drupalGet('dynamic-page-cache-test/html/uncacheable/max-age'); + $this->assertEqual('UNCACHEABLE', $this->drupalGetHeader('X-Drupal-Dynamic-Cache'), 'Render array returned, rendered as HTML response, but uncacheable: Dynamic Page Cache is running, but not caching.'); + + // 'user' cache context responses are ignored by Dynamic Page Cache. + $this->drupalGet('dynamic-page-cache-test/html/uncacheable/contexts'); + $this->assertEqual('UNCACHEABLE', $this->drupalGetHeader('X-Drupal-Dynamic-Cache'), 'Render array returned, rendered as HTML response, but uncacheable: Dynamic Page Cache is running, but not caching.'); + + // 'current-temperature' cache tag responses are ignored by Dynamic Page + // Cache. + $this->drupalGet('dynamic-page-cache-test/html/uncacheable/tags'); + $this->assertEqual('MISS', $this->drupalGetHeader('X-Drupal-Dynamic-Cache'), 'By default, Drupal has no auto-placeholdering cache tags.'); } } diff --git a/core/modules/smart_cache/tests/smart_cache_test/smart_cache_test.info.yml b/core/modules/dynamic_page_cache/tests/dynamic_page_cache_test/dynamic_page_cache_test.info.yml similarity index 35% rename from core/modules/smart_cache/tests/smart_cache_test/smart_cache_test.info.yml rename to core/modules/dynamic_page_cache/tests/dynamic_page_cache_test/dynamic_page_cache_test.info.yml index cfa52e2..7a57fd4 100644 --- a/core/modules/smart_cache/tests/smart_cache_test/smart_cache_test.info.yml +++ b/core/modules/dynamic_page_cache/tests/dynamic_page_cache_test/dynamic_page_cache_test.info.yml @@ -1,6 +1,6 @@ -name: 'Test SmartCache' +name: 'Test Dynamic Page Cache' type: module -description: 'Provides test routes/responses for SmartCache.' +description: 'Provides test routes/responses for Dynamic Page Cache.' package: Testing version: VERSION core: 8.x diff --git a/core/modules/smart_cache/tests/smart_cache_test/smart_cache_test.routing.yml b/core/modules/dynamic_page_cache/tests/dynamic_page_cache_test/dynamic_page_cache_test.routing.yml similarity index 23% rename from core/modules/smart_cache/tests/smart_cache_test/smart_cache_test.routing.yml rename to core/modules/dynamic_page_cache/tests/dynamic_page_cache_test/dynamic_page_cache_test.routing.yml index 6bd84ac..77125b6 100644 --- a/core/modules/smart_cache/tests/smart_cache_test/smart_cache_test.routing.yml +++ b/core/modules/dynamic_page_cache/tests/dynamic_page_cache_test/dynamic_page_cache_test.routing.yml @@ -1,75 +1,75 @@ -smart_cache_test.response: - path: '/smart-cache-test/response' +dynamic_page_cache_test.response: + path: '/dynamic-page-cache-test/response' defaults: - _controller: '\Drupal\smart_cache_test\SmartCacheTestController::response' + _controller: '\Drupal\dynamic_page_cache_test\DynamicPageCacheTestController::response' requirements: _access: 'TRUE' -smart_cache_test.response.admin: - path: '/smart-cache-test/response/admin' +dynamic_page_cache_test.response.admin: + path: '/dynamic-page-cache-test/response/admin' defaults: - _controller: '\Drupal\smart_cache_test\SmartCacheTestController::response' + _controller: '\Drupal\dynamic_page_cache_test\DynamicPageCacheTestController::response' requirements: _access: 'TRUE' options: _admin_route: TRUE -smart_cache_test.cacheable_response: - path: '/smart-cache-test/cacheable-response' +dynamic_page_cache_test.cacheable_response: + path: '/dynamic-page-cache-test/cacheable-response' defaults: - _controller: '\Drupal\smart_cache_test\SmartCacheTestController::cacheableResponse' + _controller: '\Drupal\dynamic_page_cache_test\DynamicPageCacheTestController::cacheableResponse' requirements: _access: 'TRUE' -smart_cache_test.cacheable_response.admin: - path: '/smart-cache-test/cacheable-response/admin' +dynamic_page_cache_test.cacheable_response.admin: + path: '/dynamic-page-cache-test/cacheable-response/admin' defaults: - _controller: '\Drupal\smart_cache_test\SmartCacheTestController::cacheableResponse' + _controller: '\Drupal\dynamic_page_cache_test\DynamicPageCacheTestController::cacheableResponse' requirements: _access: 'TRUE' options: _admin_route: TRUE -smart_cache_test.html: - path: '/smart-cache-test/html' +dynamic_page_cache_test.html: + path: '/dynamic-page-cache-test/html' defaults: - _controller: '\Drupal\smart_cache_test\SmartCacheTestController::html' + _controller: '\Drupal\dynamic_page_cache_test\DynamicPageCacheTestController::html' requirements: _access: 'TRUE' -smart_cache_test.html.admin: - path: '/smart-cache-test/html/admin' +dynamic_page_cache_test.html.admin: + path: '/dynamic-page-cache-test/html/admin' defaults: - _controller: '\Drupal\smart_cache_test\SmartCacheTestController::html' + _controller: '\Drupal\dynamic_page_cache_test\DynamicPageCacheTestController::html' requirements: _access: 'TRUE' options: _admin_route: TRUE -smart_cache_test.html.with_cache_contexts: - path: '/smart-cache-test/html/with-cache-contexts' +dynamic_page_cache_test.html.with_cache_contexts: + path: '/dynamic-page-cache-test/html/with-cache-contexts' defaults: - _controller: '\Drupal\smart_cache_test\SmartCacheTestController::htmlWithCacheContexts' + _controller: '\Drupal\dynamic_page_cache_test\DynamicPageCacheTestController::htmlWithCacheContexts' requirements: _access: 'TRUE' -smart_cache_test.html.uncacheable.max_age: - path: '/smart-cache-test/html/uncacheable/max-age' +dynamic_page_cache_test.html.uncacheable.max_age: + path: '/dynamic-page-cache-test/html/uncacheable/max-age' defaults: - _controller: '\Drupal\smart_cache_test\SmartCacheTestController::htmlUncacheableMaxAge' + _controller: '\Drupal\dynamic_page_cache_test\DynamicPageCacheTestController::htmlUncacheableMaxAge' requirements: _access: 'TRUE' -smart_cache_test.html.uncacheable.contexts: - path: '/smart-cache-test/html/uncacheable/contexts' +dynamic_page_cache_test.html.uncacheable.contexts: + path: '/dynamic-page-cache-test/html/uncacheable/contexts' defaults: - _controller: '\Drupal\smart_cache_test\SmartCacheTestController::htmlUncacheableContexts' + _controller: '\Drupal\dynamic_page_cache_test\DynamicPageCacheTestController::htmlUncacheableContexts' requirements: _access: 'TRUE' -smart_cache_test.html.uncacheable.tags: - path: '/smart-cache-test/html/uncacheable/tags' +dynamic_page_cache_test.html.uncacheable.tags: + path: '/dynamic-page-cache-test/html/uncacheable/tags' defaults: - _controller: '\Drupal\smart_cache_test\SmartCacheTestController::htmlUncacheableTags' + _controller: '\Drupal\dynamic_page_cache_test\DynamicPageCacheTestController::htmlUncacheableTags' requirements: _access: 'TRUE' diff --git a/core/modules/smart_cache/tests/smart_cache_test/src/SmartCacheTestController.php b/core/modules/dynamic_page_cache/tests/dynamic_page_cache_test/src/DynamicPageCacheTestController.php similarity index 93% rename from core/modules/smart_cache/tests/smart_cache_test/src/SmartCacheTestController.php rename to core/modules/dynamic_page_cache/tests/dynamic_page_cache_test/src/DynamicPageCacheTestController.php index c1add68..4371a29 100644 --- a/core/modules/smart_cache/tests/smart_cache_test/src/SmartCacheTestController.php +++ b/core/modules/dynamic_page_cache/tests/dynamic_page_cache_test/src/DynamicPageCacheTestController.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\smart_cache_test\SmartCacheTestController. + * Contains \Drupal\dynamic_page_cache_test\DynamicPageCacheTestController. */ -namespace Drupal\smart_cache_test; +namespace Drupal\dynamic_page_cache_test; use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Cache\CacheableResponse; @@ -13,9 +13,9 @@ use Symfony\Component\HttpFoundation\Response; /** - * Controller routines for smart_cache_test routes. + * Controller routines for dynamic_page_cache_test routes. */ -class SmartCacheTestController { +class DynamicPageCacheTestController { /** * A route returning a Response object. diff --git a/core/modules/page_cache/page_cache.module b/core/modules/page_cache/page_cache.module index 87b4be4..be051cf 100644 --- a/core/modules/page_cache/page_cache.module +++ b/core/modules/page_cache/page_cache.module @@ -21,7 +21,7 @@ function page_cache_help($route_name, RouteMatchInterface $route_match) { $output .= '
' . t('Speeding up your site') . '
'; $output .= '
' . t('Pages requested by anonymous users are stored the first time they are requested and then are reused. Depending on your site configuration and the amount of your web traffic tied to anonymous visitors, the caching system may significantly increase the speed of your site.') . '
'; $output .= '
' . t('Pages are usually identical for all anonymous users, while they can be personalized for each authenticated user. This is why entire pages can be cached for anonymous users, whereas they will have to be rebuilt for every authenticated user.') . '
'; - $output .= '
' . t('To speed up your site for authenticated users, see the Smart Cache module.', ['!smart_cache-help' => (\Drupal::moduleHandler()->moduleExists('smart_cache')) ? Url::fromRoute('help.page', ['name' => 'smart_cache'])->toString() : '#']) . '

'; + $output .= '
' . t('To speed up your site for authenticated users, see the Dynamic Page Cache module.', ['!dynamic_page_cache-help' => (\Drupal::moduleHandler()->moduleExists('dynamic_page_cache')) ? Url::fromRoute('help.page', ['name' => 'dynamic_page_cache'])->toString() : '#']) . '

'; $output .= '
' . t('Configuring the internal page cache') . '
'; $output .= '
' . t('On the Performance page, you can configure how long browsers and proxies may cache pages; that setting is also respected by the Internal Page Cache module. There is no other configuration.', array('!cache-settings' => \Drupal::url('system.performance_settings'))) . '
'; $output .= ''; diff --git a/core/modules/system/src/EventSubscriber/ConfigCacheTag.php b/core/modules/system/src/EventSubscriber/ConfigCacheTag.php index 640a6f0..7705056 100644 --- a/core/modules/system/src/EventSubscriber/ConfigCacheTag.php +++ b/core/modules/system/src/EventSubscriber/ConfigCacheTag.php @@ -61,7 +61,7 @@ public function onSave(ConfigCrudEvent $event) { } // Theme configuration and global theme settings. - if (in_array($event->getConfig()->getName(), ['system.theme', 'system.theme.global'])) { + if (in_array($event->getConfig()->getName(), ['system.theme', 'system.theme.global'], TRUE)) { $this->cacheTagsInvalidator->invalidateTags(['rendered']); } diff --git a/core/modules/system/src/Tests/Session/SessionTest.php b/core/modules/system/src/Tests/Session/SessionTest.php index 5b33bd3..037054c 100644 --- a/core/modules/system/src/Tests/Session/SessionTest.php +++ b/core/modules/system/src/Tests/Session/SessionTest.php @@ -153,10 +153,10 @@ public function testSessionPersistenceOnLogin() { * Test that empty anonymous sessions are destroyed. */ function testEmptyAnonymousSession() { - // Disable the smart_cache module; it'd cause session_test's debug output - // (that is added in SessionTestSubscriber::onKernelResponseSessionTest()) - // to not be added. - $this->container->get('module_installer')->uninstall(['smart_cache']); + // Disable the dynamic_page_cache module; it'd cause session_test's debug + // output (that is added in + // SessionTestSubscriber::onKernelResponseSessionTest()) to not be added. + $this->container->get('module_installer')->uninstall(['dynamic_page_cache']); // Verify that no session is automatically created for anonymous user when // page caching is disabled. diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 9e5d3bd..27ff1b3 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -90,7 +90,7 @@ function system_help($route_name, RouteMatchInterface $route_match) { $output .= '
' . t('Using maintenance mode') . '
'; $output .= '
' . t('When you are performing site maintenance, you can prevent non-administrative users (including anonymous visitors) from viewing your site by putting it in Maintenance mode. This will prevent unauthorized users from making changes to the site while you are performing maintenance, or from seeing a broken site while updates are in progress.', array('!maintenance-mode' => \Drupal::url('system.site_maintenance_mode'))) . '
'; $output .= '
' . t('Configuring for performance') . '
'; - $output .= '
' . t('On the Performance page, the site can be configured to aggregate CSS and JavaScript files, making the total request size smaller. Note that, for small- to medium-sized websites, the Internal Page Cache module should be installed so that pages are efficiently cached and reused for anonymous users. Finally, for websites of all sizes, the Smart Cache module should also be installed so that the non-personalized parts of pages are efficiently cached (for all users).', array('!performance-page' => \Drupal::url('system.performance_settings'), '!page-cache' => (\Drupal::moduleHandler()->moduleExists('page_cache')) ? \Drupal::url('help.page', array('name' => 'page_cache')) : '#', '!smart-cache' => (\Drupal::moduleHandler()->moduleExists('smart_cache')) ? \Drupal::url('help.page', array('name' => 'smart_cache')) : '#')) . '
'; + $output .= '
' . t('On the Performance page, the site can be configured to aggregate CSS and JavaScript files, making the total request size smaller. Note that, for small- to medium-sized websites, the Internal Page Cache module should be installed so that pages are efficiently cached and reused for anonymous users. Finally, for websites of all sizes, the Dynamic Page Cache module should also be installed so that the non-personalized parts of pages are efficiently cached (for all users).', array('!performance-page' => \Drupal::url('system.performance_settings'), '!page-cache' => (\Drupal::moduleHandler()->moduleExists('page_cache')) ? \Drupal::url('help.page', array('name' => 'page_cache')) : '#', '!dynamic-page-cache' => (\Drupal::moduleHandler()->moduleExists('dynamic_page_cache')) ? \Drupal::url('help.page', array('name' => 'dynamic_page_cache')) : '#')) . '
'; $output .= '
' . t('Configuring cron') . '
'; $output .= '
' . t('In order for the site and its modules to continue to operate well, a set of routine administrative operations must run on a regular basis; these operations are known as cron tasks. On the Cron page, you can configure cron to run periodically as part of normal page requests, or you can turn this off and trigger cron from an outside process on your web server. You can verify the status of cron tasks by visiting the Status report page. For more information, see the online documentation for configuring cron jobs.', array('!status' => \Drupal::url('system.status'), '!handbook' => 'https://www.drupal.org/cron', '!cron' => \Drupal::url('system.cron_settings'))) . '
'; $output .= '
' . t('Configuring the file system') . '
'; diff --git a/core/profiles/minimal/minimal.info.yml b/core/profiles/minimal/minimal.info.yml index 9c1d809..2617270 100644 --- a/core/profiles/minimal/minimal.info.yml +++ b/core/profiles/minimal/minimal.info.yml @@ -8,6 +8,6 @@ dependencies: - block - dblog - page_cache - - smart_cache + - dynamic_page_cache themes: - stark diff --git a/core/profiles/standard/src/Tests/StandardTest.php b/core/profiles/standard/src/Tests/StandardTest.php index a36a0a7..3b474ba 100644 --- a/core/profiles/standard/src/Tests/StandardTest.php +++ b/core/profiles/standard/src/Tests/StandardTest.php @@ -179,27 +179,27 @@ function testStandard() { $this->assertText('Max 1300x1300'); $this->assertText('Max 2600x2600'); - // Verify certain routes' responses are cacheable by SmartCache, to ensure - // these responses are very fast for authenticated users. + // Verify certain routes' responses are cacheable by Dynamic Page Cache, to + // ensure these responses are very fast for authenticated users. $this->dumpHeaders = TRUE; $this->drupalLogin($this->adminUser); $url = Url::fromRoute('contact.site_page'); $this->drupalGet($url); - $this->assertEqual('UNCACHEABLE', $this->drupalGetHeader('X-Drupal-SmartCache'), 'Site-wide contact page cannot be cached by SmartCache.'); + $this->assertEqual('UNCACHEABLE', $this->drupalGetHeader('X-Drupal-Dynamic-Cache'), 'Site-wide contact page cannot be cached by Dynamic Page Cache.'); $url = Url::fromRoute(''); $this->drupalGet($url); $this->drupalGet($url); - $this->assertEqual('HIT', $this->drupalGetHeader('X-Drupal-SmartCache'), 'Frontpage is cached by SmartCache.'); + $this->assertEqual('HIT', $this->drupalGetHeader('X-Drupal-Dynamic-Cache'), 'Frontpage is cached by Dynamic Page Cache.'); $url = Url::fromRoute('entity.node.canonical', ['node' => 1]); $this->drupalGet($url); $this->drupalGet($url); - $this->assertEqual('HIT', $this->drupalGetHeader('X-Drupal-SmartCache'), 'Full node page is cached by SmartCache.'); + $this->assertEqual('HIT', $this->drupalGetHeader('X-Drupal-Dynamic-Cache'), 'Full node page is cached by Dynamic Page Cache.'); $url = Url::fromRoute('entity.user.canonical', ['user' => 1]); $this->drupalGet($url); $this->drupalGet($url); - $this->assertEqual('HIT', $this->drupalGetHeader('X-Drupal-SmartCache'), 'User profile page is cached by SmartCache.'); + $this->assertEqual('HIT', $this->drupalGetHeader('X-Drupal-Dynamic-Cache'), 'User profile page is cached by Dynamic Page Cache.'); } } diff --git a/core/profiles/standard/standard.info.yml b/core/profiles/standard/standard.info.yml index b487f6d..68fcba2 100644 --- a/core/profiles/standard/standard.info.yml +++ b/core/profiles/standard/standard.info.yml @@ -26,7 +26,7 @@ dependencies: - options - path - page_cache - - smart_cache + - dynamic_page_cache - taxonomy - dblog - search diff --git a/core/profiles/testing/testing.info.yml b/core/profiles/testing/testing.info.yml index 8b04df4..28fc4e8 100644 --- a/core/profiles/testing/testing.info.yml +++ b/core/profiles/testing/testing.info.yml @@ -5,10 +5,10 @@ version: VERSION core: 8.x hidden: true dependencies: - # Enable page_cache and smart_cache in testing, to ensure that as many tests - # as possible run with anonymous page caching and SmartCache enabled. + # Enable page_cache and dynamic_page_cache in testing, to ensure that as many + # tests as possible run with them enabled. - page_cache - - smart_cache + - dynamic_page_cache # @todo: Remove this in https://www.drupal.org/node/2352949 themes: - classy diff --git a/sites/example.settings.local.php b/sites/example.settings.local.php index 134370a..a5d50f2 100644 --- a/sites/example.settings.local.php +++ b/sites/example.settings.local.php @@ -64,13 +64,13 @@ # $settings['cache']['bins']['render'] = 'cache.backend.null'; /** - * Disable SmartCache. + * Disable Dynamic Page Cache. * - * Note: you should test with SmartCache enabled, to ensure the correct + * Note: you should test with Dynamic Page Cache enabled, to ensure the correct * cacheability metadata is present (and hence the expected behavior). However, * in the early stages of development, you may want to disable it. */ -# $settings['cache']['bins']['smart_cache'] = 'cache.backend.null'; +# $settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null'; /** * Allow test modules and themes to be installed.