• WEBSITECM IS NOW
    Smack Digital Inc.

How To Setup MaxCDN On X-Cart

Posted by and last updated Jun 3, 2014 08:01 PM

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:
$smarty->assign('ImagesDir', $xcart_web_dir . $smarty_skin_dir . '/images');
$smarty->assign('SkinDir', $xcart_web_dir . $smarty_skin_dir);

Replace with:
(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:
$smarty->assign("SkinDir",$xcart_web_dir."/skin1");
$smarty->assign("ImagesDir",$xcart_web_dir."/skin1/images");

Replace with:
(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

About the Author

Jonathan Peters Jonathan's founder of Smack Digital, a digital strategy agency that creates and executes online business success for executives who are highly motivated to quickly increase their market share. With more than two decades of experience on the web for clients ranging from non-profits to billion dollar enterprises, Jonathan's an expert in web development, eCommerce, software programming, search engine optimization and social media marketing.

Browse By Category

RSS Feeds

Don't miss out! Subscribe to our RSS Feeds to receive instant notification when new entries are added.

RSS Feed for All Categories
RSS Feed for X-Cart How-Tos
We choose our clients selectively.
Let's talk success. Apply to work with us.
Apply toWork With Us
Apply toWork With Us