View Single Post
  #1   IP: 112.87.93.182
Old 2015-03-31, 12:43 AM
Xzavier Xzavier is offline
初级会员
 
Join Date: 2010-12-14
Posts: 4
Xzavier 现在声名狼藉
Default How To Setup MaxCDN On X-Cart

Having had the opportunity to setup MaxCDN for a number of X-Cart sites we've found this solution to be the most reliable to deliver CDN content.


Setting up a CDN for your medium to large X-Cart site will help improve its loading times across the world by delivering static content from the MaxCDN server located closest to your customer. Google uses site loading times as a factor in search engine ranking so for sites with steady sales and traffic we recommend implementing a CDN like MaxCDN.

X-Cart 4.4/4.5

X-Cart versions 4.4 and can add complexity to a CDN setup when using alternate skin folders and/or javascript/css speed compression settings. Our CDN setup service will evaluate your site and implement the CDN in the way that provides the absolute best speed benefit to your site. If these are not an issue on your site, you can implement as follows:

Open smarty.php
Find:
Code:
$smarty->assign('ImagesDir', $xcart_web_dir . $smarty_skin_dir . '/images');
$smarty->assign('SkinDir', $xcart_web_dir . $smarty_skin_dir);
Replace with:
Code:
(Be sure to replace cdnurl.example.com with your CDN Url)
// WCM - MaxCDN Implementation
if ($_SERVER['HTTPS'] != 'on')
{
$smarty->assign('ImagesDir',        "http://cdnurl.example.com" . $smarty_skin_dir . '/images');
$smarty->assign('SkinDir',        "http://cdnurl.example.com" . $smarty_skin_dir);
}
else
{
$smarty->assign('ImagesDir', $xcart_web_dir . $smarty_skin_dir . '/images');
$smarty->assign('SkinDir', $xcart_web_dir . $smarty_skin_dir);
}

X-Cart 4.3 and lower

For X-Cart versions 4.3 and lower, you can implement a CDN fairly easily as follows:

Open smarty.php
Find:
Code:
$smarty->assign("SkinDir",$xcart_web_dir."/skin1");
$smarty->assign("ImagesDir",$xcart_web_dir."/skin1/images");
Replace with:
Code:
(Be sure to replace cdnurl.example.com with your CDN Url)
// WCM - MaxCDN Implementation
if ($_SERVER['HTTPS'] != 'on')
{
$smarty->assign('SkinDir', 'http://cdnurl.example.com/skin1');
$smarty->assign('ImagesDir', 'http://cdnurl.example.com/skin1/images');
}
else
{
$smarty->assign("SkinDir",$xcart_web_dir."/skin1");
$smarty->assign("ImagesDir",$xcart_web_dir."/skin1/images");
}
// / WCM - MaxCDN Implementation
Reply With Quote