From a2551812f5976adc4101defc4e132e9fffa7f26f Mon Sep 17 00:00:00 2001
From: Nathaniel Catchpole <catch@35733.no-reply.drupal.org>
Date: Fri, 24 Oct 2014 16:58:22 +0100
Subject: [PATCH] Issue #2183075 by valderama, dinarcon, er.pushpinderrana,
 amitgoyal, umar-ahmad: Tidy up css.gzip and js.gzip configuration.

---
 core/includes/common.inc                   |  4 ++--
 core/lib/Drupal/Core/Asset/AssetDumper.php |  2 +-
 sites/default/default.settings.php         | 15 ---------------
 3 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/core/includes/common.inc b/core/includes/common.inc
index 020d84d8992b..3545e05ee667 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -2237,8 +2237,8 @@ function drupal_clear_js_cache() {
  */
 function drupal_page_set_cache(Response $response, Request $request) {
   // Check if the current page may be compressed.
-  if (\Drupal::config('system.performance')->get('response.gzip') &&
-    !$response->headers->get('Content-Encoding') && extension_loaded('zlib')) {
+  if (extension_loaded('zlib') && !$response->headers->get('Content-Encoding') &&
+      \Drupal::config('system.performance')->get('response.gzip')) {
 
     $content = $response->getContent();
     if ($content) {
diff --git a/core/lib/Drupal/Core/Asset/AssetDumper.php b/core/lib/Drupal/Core/Asset/AssetDumper.php
index 7ff85ed887d6..d5283bfc9239 100644
--- a/core/lib/Drupal/Core/Asset/AssetDumper.php
+++ b/core/lib/Drupal/Core/Asset/AssetDumper.php
@@ -41,7 +41,7 @@ public function dump($data, $file_extension) {
     // file) in generating the file anyway. Sites on servers where rewrite rules
     // aren't working can set css.gzip to FALSE in order to skip
     // generating a file that won't be used.
-    if (\Drupal::config('system.performance')->get($file_extension . '.gzip') && extension_loaded('zlib')) {
+    if (extension_loaded('zlib') && \Drupal::config('system.performance')->get($file_extension . '.gzip')) {
       if (!file_exists($uri . '.gz') && !file_unmanaged_save_data(gzencode($data, 9, FORCE_GZIP), $uri . '.gz', FILE_EXISTS_REPLACE)) {
         return FALSE;
       }
diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php
index 3936dcb4630e..cc2eb327d625 100644
--- a/sites/default/default.settings.php
+++ b/sites/default/default.settings.php
@@ -585,21 +585,6 @@
 # $config['system.theme']['default'] = 'stark';
 # $config['user.settings']['anonymous'] = 'Visitor';
 
-/**
- * CSS/JS aggregated file gzip compression:
- *
- * By default, when CSS or JS aggregation and clean URLs are enabled Drupal will
- * store a gzip compressed (.gz) copy of the aggregated files. If this file is
- * available then rewrite rules in the default .htaccess file will serve these
- * files to browsers that accept gzip encoded content. This allows pages to load
- * faster for these users and has minimal impact on server load. If you are
- * using a webserver other than Apache httpd, or a caching reverse proxy that is
- * configured to cache and compress these files itself you may want to uncomment
- * one or both of the below lines, which will prevent gzip files being stored.
- */
-# $config['system.performance']['css']['gzip'] = FALSE;
-# $config['system.performance']['js']['gzip'] = FALSE;
-
 /**
  * Fast 404 pages:
  *
-- 
GitLab