优化静态发布页面的速度

hotfix/paypal-note
尹诚诚 4 years ago
parent 781c5522fb
commit 22912b56b4

@ -414,15 +414,14 @@ class Information extends CI_Controller
$recommand_information = $this->recommand_information($information);
//$this->benchmark->mark('111');
$this->make_www_cache('mobile', $information_new, $recommand_information);
//$this->benchmark->mark('222');
$this->make_www_cache('pc', $information_new, $recommand_information);
//echo ' |000~111: '.$this->benchmark->elapsed_time('000', '111');
//echo ' |111~222: '.$this->benchmark->elapsed_time('111', '222');
} else if (strcasecmp($site_code, "ah") == 0 && !empty($auto_update_cache)) {
//读取模板生成PC和移动优先文件
$recommand_information = $this->recommand_information($information);
$information_new = $this->Information_model->Detail($this->input->post('is_id'));
$this->make_www_cache_ah('mobile', $information_new);
$this->make_www_cache_ah('pc', $information_new);
$this->make_www_cache_ah('mobile', $information_new,$recommand_information);
$this->make_www_cache_ah('pc', $information_new,$recommand_information);
} else if (strcasecmp($site_code, "gh") == 0 && !empty($auto_update_cache)) {
$information_new = $this->Information_model->Detail($this->input->post('is_id'));
$this->make_www_cache_gh($information_new);
@ -928,7 +927,7 @@ class Information extends CI_Controller
}
function make_www_cache_ah($device, $information)
function make_www_cache_ah($device, $information, $recommand_information)
{
$data = array();
@ -988,7 +987,7 @@ class Information extends CI_Controller
//推荐信息或者产品
//信息推荐
$template_recommand = $this->recommand_information($information);
$template_recommand =$recommand_information;// $this->recommand_information($information);
$template = str_replace('<!--@ARTICLENEXT@-->', $this->load->view($template_path . '-next', array('recommands' => $template_recommand), TRUE), $template);
//广告改叫tips防止被插件屏蔽
if (!empty($template_recommand['Tips Right'])) {
@ -1012,7 +1011,11 @@ class Information extends CI_Controller
}
//主样式表,内联模式
$main_css_string = compress_css(GET_HTTP('https://proxy-data.asiahighlights.com/css/mobile-first.css'));
if (is_file('D:/wwwroot/origin-www.asiahighlights.com/css/mobile-first.css')) {//主样式表,内联模式,优先读取本地,没有在从网络读取,为了加速
$main_css_string = compress_css(file_get_contents('D:/wwwroot/origin-www.asiahighlights.com/css/mobile-first.css'));
} else {
$main_css_string = compress_css(GET_HTTP('https://proxy-data.asiahighlights.com/css/mobile-first.css'));
}
$template = str_replace('<!--@MAIN-CSS@-->', '<style type="text/css">' . $main_css_string . '</style>', $template);
//额外样式
$meta_addon_css = get_meta($information->ic_id, 'meta_addon_css');
@ -1059,7 +1062,11 @@ class Information extends CI_Controller
}
//设置图片尺寸
$template = $this->html_optimize_lib->set_image_size($template);
if (is_dir('D:/wwwroot/origin-images.chinahighlights.com') && is_dir('D:/wwwroot/origin-www.asiahighlights.com')) {
$template = $this->html_optimize_lib->set_image_size_local($template, 'D:/wwwroot/origin-www.asiahighlights.com', 'D:/wwwroot/origin-images.chinahighlights.com');
} else {
$template = $this->html_optimize_lib->set_image_size($template);
}
// /travelguide/chinese-zodiac/monthly-fortune-for-dog.htm
$html_path = $this->config->item('cache')[$this->config->item('site_code')]['cache_path'] . $information->ic_url;
$html_path = str_replace("\\", "/", $html_path);

Loading…
Cancel
Save