فهرست منبع

#158 - Very slow CSS cache creation when Minify is used.

AntonLV 11 سال پیش
والد
کامیت
e4be52a073

+ 5 - 8
inc/classes/BxDolTemplate.php

@@ -157,10 +157,12 @@ class BxDolTemplate extends BxDol implements iBxDolSingleton
     protected $_iImagesMaxSize;
 
     protected $_bCssCache;
+    protected $_bCssMinify;
     protected $_bCssArchive;
     protected $_sCssCachePrefix;
 
     protected $_bJsCache;
+    protected $_bJsMinify;
     protected $_bJsArchive;
     protected $_sJsCachePrefix;
 
@@ -170,11 +172,6 @@ class BxDolTemplate extends BxDol implements iBxDolSingleton
     protected $_bLessEnable;
     protected $_sLessCachePrefix;
 
-    /**
-     * Minify related fields
-     */
-    protected $_bMinifyEnable;
-
     protected $aPage;
     protected $aPageContent;
 
@@ -247,18 +244,18 @@ class BxDolTemplate extends BxDol implements iBxDolSingleton
 
         $bArchive = getParam('sys_template_cache_compress_enable') == 'on';
         $this->_bCssCache = !defined('BX_DOL_CRON_EXECUTE') && getParam('sys_template_cache_css_enable') == 'on';
+        $this->_bCssMinify = $this->_bCssCache && getParam('sys_template_cache_minify_css_enable') == 'on';
         $this->_bCssArchive = $this->_bCssCache && $bArchive;
         $this->_sCssCachePrefix = $this->_sCacheFilePrefix . 'css_';
 
         $this->_bJsCache = !defined('BX_DOL_CRON_EXECUTE') && getParam('sys_template_cache_js_enable') == 'on';
+        $this->_bJsMinify = $this->_bJsCache && getParam('sys_template_cache_minify_js_enable') == 'on';
         $this->_bJsArchive = $this->_bJsCache && $bArchive;
         $this->_sJsCachePrefix = $this->_sCacheFilePrefix . 'js_';
 
         $this->_bLessEnable = true;
         $this->_sLessCachePrefix = $this->_sCacheFilePrefix . 'less_';
 
-        $this->_bMinifyEnable = true;
-
         $this->aPage = array();
         $this->aPageContent = array();
     }
@@ -1577,7 +1574,7 @@ class BxDolTemplate extends BxDol implements iBxDolSingleton
                 $sResult .= $sContent;
         }
 
-        if ($this->_bMinifyEnable && method_exists($this, $sMethodMinify))
+        if ($this->{'_b' . $sUpcaseType . 'Minify'})
             $sResult = $this->$sMethodMinify($sResult);
 
         $mixedWriteResult = false;

+ 3 - 1
install/sql/system.sql

@@ -297,7 +297,9 @@ INSERT INTO `sys_options`(`category_id`, `name`, `caption`, `value`, `type`, `ex
 (@iCategoryId, 'sys_template_cache_engine', '_adm_stg_cpt_option_sys_template_cache_engine', 'FileHtml', 'select', 'FileHtml,EAccelerator,Memcache,APC,XCache', '', '', 51),
 (@iCategoryId, 'sys_template_cache_css_enable', '_adm_stg_cpt_option_sys_template_cache_css_enable', 'on', 'checkbox', '', '', '', 55),
 (@iCategoryId, 'sys_template_cache_js_enable', '_adm_stg_cpt_option_sys_template_cache_js_enable', 'on', 'checkbox', '', '', '', 56),
-(@iCategoryId, 'sys_template_cache_compress_enable', '_adm_stg_cpt_option_sys_template_cache_compress_enable', 'on', 'checkbox', '', '', '', 57);
+(@iCategoryId, 'sys_template_cache_minify_css_enable', '_adm_stg_cpt_option_sys_template_cache_minify_css_enable', 'on', 'checkbox', '', '', '', 57),
+(@iCategoryId, 'sys_template_cache_minify_js_enable', '_adm_stg_cpt_option_sys_template_cache_minify_js_enable', 'on', 'checkbox', '', '', '', 58),
+(@iCategoryId, 'sys_template_cache_compress_enable', '_adm_stg_cpt_option_sys_template_cache_compress_enable', 'on', 'checkbox', '', '', '', 59);
 
 
 --

+ 2 - 0
modules/boonex/english/data/langs/system/en.xml

@@ -1165,6 +1165,8 @@
 	<string name="_adm_stg_cpt_option_sys_template_cache_enable"><![CDATA[Enable cache for HTML files]]></string>
 	<string name="_adm_stg_cpt_option_sys_template_cache_engine"><![CDATA[Template cache engine (other than FileHtml option may require custom server setup)]]></string>
 	<string name="_adm_stg_cpt_option_sys_template_cache_js_enable"><![CDATA[Enable cache for JS files]]></string>
+	<string name="_adm_stg_cpt_option_sys_template_cache_minify_css_enable"><![CDATA[Enable lessening for CSS files (cache should be enabled)]]></string>
+	<string name="_adm_stg_cpt_option_sys_template_cache_minify_js_enable"><![CDATA[Enable lessening for JS files (cache should be enabled)]]></string>
 	<string name="_adm_stg_cpt_option_sys_transcoder_queue_storage"><![CDATA[Remote video transcoding]]></string>
 	<string name="_adm_stg_cpt_option_template"><![CDATA[Default Template]]></string>
 	<string name="_adm_stg_err_option_template"><![CDATA[Template cannot be empty and must have a valid name.]]></string>

+ 2 - 0
modules/boonex/russian/data/langs/system/ru.xml

@@ -1165,6 +1165,8 @@
 	<string name="_adm_stg_cpt_option_sys_template_cache_enable"><![CDATA[Задействовать кэш для файлов HTML]]></string>
 	<string name="_adm_stg_cpt_option_sys_template_cache_engine"><![CDATA[Кэш-движок для темы (темплейта) (отличный от FileHtml может потребовать дополнительную настройку сервера)]]></string>
 	<string name="_adm_stg_cpt_option_sys_template_cache_js_enable"><![CDATA[Задействовать кэш для файлов JS]]></string>
+	<string name="_adm_stg_cpt_option_sys_template_cache_minify_css_enable"><![CDATA[Задействовать уменьшение для файлов CSS (кэш должен быть задействован)]]></string>
+	<string name="_adm_stg_cpt_option_sys_template_cache_minify_js_enable"><![CDATA[Задействовать уменьшение для файлов JS (кэш должен быть задействован)]]></string>
 	<string name="_adm_stg_cpt_option_sys_transcoder_queue_storage"><![CDATA[Удалённая раскодировка видео]]></string>
 	<string name="_adm_stg_cpt_option_template"><![CDATA[Основная Тема]]></string>
 	<string name="_adm_stg_err_option_template"><![CDATA[Тема не может быть пустой и должна иметь приемлемое название.]]></string>