core/modules/file/src/Tests/DownloadTest.php | 2 +- .../image/src/Tests/ImageStylesPathAndUrlTest.php | 2 +- .../src/Tests/d6/MigrateSystemPerformanceTest.php | 1 - .../page_cache/src/StackMiddleware/PageCache.php | 14 ------ .../modules/page_cache/src/Tests/PageCacheTest.php | 53 ---------------------- .../system/config/install/system.performance.yml | 2 - core/modules/system/src/Form/PerformanceForm.php | 11 ----- .../system/src/Tests/Session/SessionTest.php | 2 +- 8 files changed, 3 insertions(+), 84 deletions(-) diff --git a/core/modules/file/src/Tests/DownloadTest.php b/core/modules/file/src/Tests/DownloadTest.php index 130b07c..4df65e5 100644 --- a/core/modules/file/src/Tests/DownloadTest.php +++ b/core/modules/file/src/Tests/DownloadTest.php @@ -56,7 +56,7 @@ public function testPrivateFileTransferWithoutPageCache() { */ public function testPrivateFileTransferWithPageCache() { // Turn on page caching and rerun the test. - $this->assertTrue($this->container->get('module_installer')->install(['page_cache']), 'Page cache module installed.'); + $this->container->get('module_installer')->install(['page_cache']); $config = $this->config('system.performance'); $config->set('cache.page.max_age', 300); $config->save(); diff --git a/core/modules/image/src/Tests/ImageStylesPathAndUrlTest.php b/core/modules/image/src/Tests/ImageStylesPathAndUrlTest.php index ebaa81c..88cf620 100644 --- a/core/modules/image/src/Tests/ImageStylesPathAndUrlTest.php +++ b/core/modules/image/src/Tests/ImageStylesPathAndUrlTest.php @@ -247,7 +247,7 @@ function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_slash = */ protected function enablePageCache() { // Turn on page caching and rerun the test. - $this->assertTrue($this->container->get('module_installer')->install(['page_cache']), 'Page cache module installed.'); + $this->container->get('module_installer')->install(['page_cache']); $config = $this->config('system.performance'); $config->set('cache.page.max_age', 300); $config->save(); diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateSystemPerformanceTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateSystemPerformanceTest.php index 50d6c51..933ccb7 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateSystemPerformanceTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateSystemPerformanceTest.php @@ -40,7 +40,6 @@ public function testSystemPerformance() { $this->assertIdentical($config->get('css.preprocess'), FALSE); $this->assertIdentical($config->get('js.preprocess'), FALSE); $this->assertIdentical($config->get('cache.page.max_age'), 0); - $this->assertIdentical($config->get('response.gzip'), TRUE); } } diff --git a/core/modules/page_cache/src/StackMiddleware/PageCache.php b/core/modules/page_cache/src/StackMiddleware/PageCache.php index 60afa5d..66a5f88 100644 --- a/core/modules/page_cache/src/StackMiddleware/PageCache.php +++ b/core/modules/page_cache/src/StackMiddleware/PageCache.php @@ -231,20 +231,6 @@ protected function fetch(Request $request, $type = self::MASTER_REQUEST, $catch return $response; } - // Check if the current page may be compressed. - if (extension_loaded('zlib') && !$response->headers->get('Content-Encoding') && $this->config('system.performance')->get('response.gzip')) { - $content = $response->getContent(); - if ($content) { - $response->setContent(gzencode($content, 9, FORCE_GZIP)); - $response->headers->set('Content-Encoding', 'gzip'); - } - - // When page compression is enabled, ensure that proxy caches will record - // and deliver different versions of a page depending on whether the - // client supports gzip or not. - $response->setVary('Accept-Encoding', FALSE); - } - // Use the actual timestamp from an Expires header, if available. $date = $response->getExpires(); $expire = ($date > (new \DateTime())) ? $date->getTimestamp() : Cache::PERMANENT; diff --git a/core/modules/page_cache/src/Tests/PageCacheTest.php b/core/modules/page_cache/src/Tests/PageCacheTest.php index 0aef91f..8e59765 100644 --- a/core/modules/page_cache/src/Tests/PageCacheTest.php +++ b/core/modules/page_cache/src/Tests/PageCacheTest.php @@ -138,14 +138,9 @@ function testConditionalRequests() { * Tests cache headers. */ function testPageCache() { - $config = $this->config('system.performance'); - $config->set('response.gzip', 1); - $config->save(); - // Fill the cache. $this->drupalGet('system-test/set-header', array('query' => array('name' => 'Foo', 'value' => 'bar'))); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.'); - $this->assertEqual(strtolower($this->drupalGetHeader('Vary')), 'cookie,accept-encoding', 'Vary header was sent.'); // Symfony's Response logic determines a specific order for the subvalues // of the Cache-Control header, even if they are explicitly passed in to // the response header bag in a different order. @@ -156,7 +151,6 @@ function testPageCache() { // Check cache. $this->drupalGet('system-test/set-header', array('query' => array('name' => 'Foo', 'value' => 'bar'))); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.'); - $this->assertEqual(strtolower($this->drupalGetHeader('Vary')), 'cookie,accept-encoding', 'Vary: Cookie header was sent.'); $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'max-age=300, public', 'Cache-Control header was sent.'); $this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', 'Expires header was sent.'); $this->assertEqual($this->drupalGetHeader('Foo'), 'bar', 'Custom header was sent.'); @@ -165,14 +159,12 @@ function testPageCache() { $this->drupalGet('system-test/set-header', array('query' => array('name' => 'Expires', 'value' => 'Fri, 19 Nov 2008 05:00:00 GMT'))); $this->assertEqual($this->drupalGetHeader('Expires'), 'Fri, 19 Nov 2008 05:00:00 GMT', 'Default header was replaced.'); $this->drupalGet('system-test/set-header', array('query' => array('name' => 'Vary', 'value' => 'User-Agent'))); - $this->assertEqual(strtolower($this->drupalGetHeader('Vary')), 'user-agent,accept-encoding', 'Default header was replaced.'); // Check that authenticated users bypass the cache. $user = $this->drupalCreateUser(); $this->drupalLogin($user); $this->drupalGet('system-test/set-header', array('query' => array('name' => 'Foo', 'value' => 'bar'))); $this->assertFalse($this->drupalGetHeader('X-Drupal-Cache'), 'Caching was bypassed.'); - $this->assertTrue(strpos(strtolower($this->drupalGetHeader('Vary')), 'cookie') === FALSE, 'Vary: Cookie header was not sent.'); $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'must-revalidate, no-cache, post-check=0, pre-check=0, private', 'Cache-Control header was sent.'); $this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', 'Expires header was sent.'); $this->assertEqual($this->drupalGetHeader('Foo'), 'bar', 'Custom header was sent.'); @@ -199,49 +191,4 @@ public function testPageCacheWithoutVaryCookie() { $this->assertTrue(strpos($this->drupalGetHeader('Vary'), 'Cookie') === FALSE, 'Vary: Cookie header was not sent.'); } - /** - * Tests page compression. - * - * The test should pass even if zlib.output_compression is enabled in php.ini, - * .htaccess or similar, or if compression is done outside PHP, e.g. by the - * mod_deflate Apache module. - */ - function testPageCompression() { - $config = $this->config('system.performance'); - $config->set('response.gzip', 1); - $config->save(); - - // Fill the cache and verify that output is compressed. - $this->drupalGet('', array(), array('Accept-Encoding: gzip,deflate')); - $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.'); - $this->drupalSetContent(gzinflate(substr($this->drupalGetContent(), 10, -8))); - $this->assertRaw('', 'Page was gzip compressed.'); - - // Verify that cached output is compressed. - $this->drupalGet('', array(), array('Accept-Encoding: gzip,deflate')); - $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.'); - $this->assertEqual($this->drupalGetHeader('Content-Encoding'), 'gzip', 'A Content-Encoding header was sent.'); - $this->drupalSetContent(gzinflate(substr($this->drupalGetContent(), 10, -8))); - $this->assertRaw('', 'Page was gzip compressed.'); - - // Verify that a client without compression support gets an uncompressed page. - $this->drupalGet(''); - $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.'); - $this->assertFalse($this->drupalGetHeader('Content-Encoding'), 'A Content-Encoding header was not sent.'); - $this->assertTitle(t('Test page | @site-name', array('@site-name' => $this->config('system.site')->get('name'))), 'Site title matches.'); - $this->assertRaw('', 'Page was not compressed.'); - - // Disable compression mode. - $config->set('response.gzip', 0); - $config->save(); - - // Verify if cached page is still available for a client with compression support. - $this->drupalGet('', array(), array('Accept-Encoding: gzip,deflate')); - $this->drupalSetContent(gzinflate(substr($this->drupalGetContent(), 10, -8))); - $this->assertRaw('', 'Page was delivered after compression mode is changed (compression support enabled).'); - - // Verify if cached page is still available for a client without compression support. - $this->drupalGet(''); - $this->assertRaw('', 'Page was delivered after compression mode is changed (compression support disabled).'); - } } diff --git a/core/modules/system/config/install/system.performance.yml b/core/modules/system/config/install/system.performance.yml index 058f9e8..11392bd 100644 --- a/core/modules/system/config/install/system.performance.yml +++ b/core/modules/system/config/install/system.performance.yml @@ -12,6 +12,4 @@ fast_404: js: preprocess: true gzip: true -response: - gzip: false stale_file_threshold: 2592000 diff --git a/core/modules/system/src/Form/PerformanceForm.php b/core/modules/system/src/Form/PerformanceForm.php index e007df9..c5eb48c 100644 --- a/core/modules/system/src/Form/PerformanceForm.php +++ b/core/modules/system/src/Form/PerformanceForm.php @@ -151,16 +151,6 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#description' => t('External resources can be optimized automatically, which can reduce both the size and number of requests made to your website.') . $disabled_message, ); - $form['bandwidth_optimization']['page_compression'] = array( - '#type' => 'checkbox', - '#title' => t('Compress cached pages'), - '#default_value' => $config->get('response.gzip'), - '#states' => array( - 'visible' => array( - 'input[name="cache"]' => array('checked' => TRUE), - ), - ), - ); $form['bandwidth_optimization']['preprocess_css'] = array( '#type' => 'checkbox', '#title' => t('Aggregate CSS files'), @@ -190,7 +180,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('system.performance') ->set('cache.page.max_age', $form_state->getValue('page_cache_maximum_age')) - ->set('response.gzip', $form_state->getValue('page_compression')) ->set('css.preprocess', $form_state->getValue('preprocess_css')) ->set('js.preprocess', $form_state->getValue('preprocess_js')) ->save(); diff --git a/core/modules/system/src/Tests/Session/SessionTest.php b/core/modules/system/src/Tests/Session/SessionTest.php index 95eae11..d6cea95 100644 --- a/core/modules/system/src/Tests/Session/SessionTest.php +++ b/core/modules/system/src/Tests/Session/SessionTest.php @@ -144,7 +144,7 @@ function testEmptyAnonymousSession() { $this->assertSessionEmpty(TRUE); // The same behavior is expected when caching is enabled. - $this->assertTrue($this->container->get('module_installer')->install(['page_cache']), 'Page cache module installed.'); + $this->container->get('module_installer')->install(['page_cache']); $config = $this->config('system.performance'); $config->set('cache.page.max_age', 300); $config->save();