 core/includes/common.inc                           |   19 +-----------
 .../Core/EventSubscriber/HtmlViewSubscriber.php    |   32 +++++++++++++++++++-
 .../Core/Page/DefaultHtmlFragmentRenderer.php      |    4 +++
 .../Tests/Cache/PageCacheTagsIntegrationTest.php   |    7 +++--
 4 files changed, 41 insertions(+), 21 deletions(-)

diff --git a/core/includes/common.inc b/core/includes/common.inc
index ecdce53..3dc86d1 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -3243,7 +3243,7 @@ function drupal_page_set_cache(Response $response, Request $request) {
         // because by the time it is read, the configuration might change.
         'page_compressed' => $page_compressed,
       ),
-      'tags' => array('content' => TRUE) + drupal_cache_tags_page_get($response),
+      'tags' => explode(' ', $response->headers->get('X-Drupal-Cache-Tags')),
       'expire' => Cache::PERMANENT,
       'created' => REQUEST_TIME,
     );
@@ -4486,23 +4486,6 @@ function drupal_render_collect_cache_tags($element, $tags = array()) {
 }
 
 /**
- * Return the cache tags that were stored during drupal_render_page().
- *
- * @param \Symfony\Component\HttpFoundation\Response $response
- *   The response object.
- * @return array
- *   An array of cache tags.
- *
- * @see \Drupal\Core\EventSubscriber\HtmlViewSubscriber::onHtmlPage()
- */
-function drupal_cache_tags_page_get(Response $response) {
-  if (($tags = $response->headers->get('cache_tags')) && $tags = unserialize($tags)) {
-    return $tags;
-  }
-  return array();
-}
-
-/**
  * Prepares an element for caching based on a query.
  *
  * This smart caching strategy saves Drupal from querying and rendering to HTML
diff --git a/core/lib/Drupal/Core/EventSubscriber/HtmlViewSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/HtmlViewSubscriber.php
index 69e80cd..e5c5e57 100644
--- a/core/lib/Drupal/Core/EventSubscriber/HtmlViewSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/HtmlViewSubscriber.php
@@ -77,7 +77,7 @@ public function onHtmlPage(GetResponseForControllerResultEvent $event) {
       // recommended.
       $response = new Response((string) $this->pageRenderer->render($page), $page->getStatusCode());
       if ($tags = $page->getCacheTags()) {
-        $response->headers->set('cache_tags', serialize($tags));
+        $response->headers->set('X-Drupal-Cache-Tags', $this->flattenTags($tags));
       }
       if ($keys = $page->getCacheKeys()) {
         $response->headers->set('cache_keys', serialize($keys));
@@ -93,6 +93,36 @@ public function onHtmlPage(GetResponseForControllerResultEvent $event) {
   }
 
   /**
+   * 'Flattens' a cache tags array into a space-separated flattened tags list.
+   *
+   * @param array $tags
+   *   Associative array of tags to flatten.
+   *
+   * @return string
+   *   A space-separated list of flattened tags.
+   *
+   * @see \Drupal\Core\Cache\DatabaseBackend::flattenTags()
+   */
+  protected function flattenTags(array $tags) {
+    if (isset($tags[0])) {
+      return $tags;
+    }
+
+    $flat_tags = array();
+    foreach ($tags as $namespace => $values) {
+      if (is_array($values)) {
+        foreach ($values as $value) {
+          $flat_tags[] = "$namespace:$value";
+        }
+      }
+      else {
+        $flat_tags[] = "$namespace:$values";
+      }
+    }
+    return implode(' ', $flat_tags);
+  }
+
+  /**
    * Registers the methods in this class that should be listeners.
    *
    * @return array
diff --git a/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php b/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php
index 64aed01..748b59b 100644
--- a/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php
+++ b/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php
@@ -51,6 +51,10 @@ public function render(HtmlFragment $fragment, $status_code = 200) {
     // Collect cache tags for all the content in all the regions on the page.
     $tags = drupal_render_collect_cache_tags($page_array);
 
+    // Enforce the generic "content" cache tag on all pages.
+    // @todo Remove the "content" cache tag. @see https://drupal.org/node/2124957
+    $tags['content'] = TRUE;
+
     // Build the HtmlPage object.
     $page = new HtmlPage('', array('tags' => $tags), $fragment->getTitle());
     $page = $this->preparePage($page, $page_array);
diff --git a/core/modules/system/lib/Drupal/system/Tests/Cache/PageCacheTagsIntegrationTest.php b/core/modules/system/lib/Drupal/system/Tests/Cache/PageCacheTagsIntegrationTest.php
index b245c34..2dffc4f 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Cache/PageCacheTagsIntegrationTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Cache/PageCacheTagsIntegrationTest.php
@@ -66,24 +66,24 @@ function testPageCacheTags() {
 
     // Full node page 1.
     $this->verifyPageCacheTags('node/' . $node_1->id(), array(
-      'content:1',
       'node_view:1',
       'node:' . $node_1->id(),
       'user:' . $author_1->id(),
       'filter_format:basic_html',
       'menu:footer',
       'menu:main',
+      'content:1',
     ));
 
     // Full node page 2.
     $this->verifyPageCacheTags('node/' . $node_2->id(), array(
-      'content:1',
       'node_view:1',
       'node:' . $node_2->id(),
       'user:' . $author_2->id(),
       'filter_format:full_html',
       'menu:footer',
       'menu:main',
+      'content:1',
     ));
   }
 
@@ -96,10 +96,13 @@ function testPageCacheTags() {
    *   The expected cache tags for the page cache entry of the given $path.
    */
   protected function verifyPageCacheTags($path, $expected_tags) {
+    $expected_tags_header = implode(' ', $expected_tags);
     $this->drupalGet($path);
     $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS');
+    $this->assertIdentical($this->drupalGetHeader('X-Drupal-Cache-Tags'), $expected_tags_header);
     $this->drupalGet($path);
     $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
+    $this->assertIdentical($this->drupalGetHeader('X-Drupal-Cache-Tags'), $expected_tags_header);
     $cid_parts = array(url($path, array('absolute' => TRUE)), 'html');
     $cid = sha1(implode(':', $cid_parts));
     $cache_entry = \Drupal::cache('page')->get($cid);
