Skip to content

Commit

Permalink
dtm: desactivate HTML minifier if cache system is off increase perfor…
Browse files Browse the repository at this point in the history
…mance
  • Loading branch information
GGRei committed Feb 7, 2024
1 parent c537d28 commit 7929b66
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion vlib/x/templating/dtm/dynamic_template_manager.v
Expand Up @@ -189,6 +189,7 @@ pub fn initialize(dtm_init_params DynamicTemplateManagerInitialisationParams) &D
mut active_cache_handler := dtm_init_params.active_cache_server
mut system_ready := true
mut cache_temporary_bool := false
mut minified_html := dtm_init_params.compress_html
$if test {
dir_path = dtm_init_params.test_cache_dir
dir_html_path = dtm_init_params.test_template_dir
Expand Down Expand Up @@ -224,11 +225,16 @@ pub fn initialize(dtm_init_params DynamicTemplateManagerInitialisationParams) &D
}
// If it is impossible to use a cache directory, the cache system is deactivated, and the user is warned."
if !active_cache_handler {
// If the cache server is not used, the HTML minifier is disabled, which increases the performance of pure generation without caching
minified_html = false
eprintln('${dtm.message_signature_warn} The cache storage directory does not exist or has a problem and it was also not possible to use a folder suitable for temporary storage. Therefore, the cache system will be disabled. It is recommended to address the aforementioned issues to utilize the cache system.')
} else {
cache_temporary_bool = true
}
}
} else {
// If the cache server is not used, the HTML minifier is disabled, which increases the performance of pure generation without caching
minified_html = false
}
// Control if 'templates' folder exist in the root project
if !os.exists(dir_html_path) && !os.is_dir(dir_html_path) {
Expand All @@ -252,7 +258,7 @@ pub fn initialize(dtm_init_params DynamicTemplateManagerInitialisationParams) &D
template_cache_folder: dir_path
template_folder: dir_html_path
max_size_data_in_memory: max_size_memory
compress_html: dtm_init_params.compress_html
compress_html: minified_html
active_cache_server: active_cache_handler
c_time: get_current_unix_micro_timestamp()
dtm_init_is_ok: system_ready
Expand Down

0 comments on commit 7929b66

Please sign in to comment.