X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Third Party Add-Ons for X-Cart 4 (https://forum.x-cart.com/forumdisplay.php?f=45)
-   -   MaxCDN Content Delivery Solution? (https://forum.x-cart.com/showthread.php?t=55319)

Jon 10-05-2010 08:24 AM

Re: MaxCDN Content Delivery Solution?
 
On our 4.1.x here's how we did our thumbnail and product images.

Open include/func/func.files.php

FIND:

Code:

if (!strncmp($xcart_dir, $image_path, strlen($xcart_dir)) && @file_exists($image_path)) {

BEFORE add:

Code:

// WCM - CDN Images
if (($type == 'T' OR $type == 'P') AND $_SERVER['HTTPS'] != 'on')
        return str_replace('/home/path/to/your/images/','http://cdn.example.com/',$image_path);
// / WCM - CDN Images


Stizerg 11-02-2010 01:46 AM

Re: MaxCDN Content Delivery Solution?
 
Hi Jon!
I tried your code, but as result I get replaced url appended to mydomainname.
It looks like: 'http://www.mydomainname.com/http://cdn.example.com/'

Any idea?

Jon 11-05-2010 06:37 AM

Re: MaxCDN Content Delivery Solution?
 
Try:

// WCM - CDN Images
if (($type == 'T' OR $type == 'P') AND $_SERVER['HTTPS'] != 'on')
{
$image_path = str_replace('/home/path/to/your/images/','',$image_path);
return str_replace('$http_location','',$image_path);
}
// / WCM - CDN Images

Stizerg 11-05-2010 03:33 PM

Re: MaxCDN Content Delivery Solution?
 
Brilliant! Thanks Jon.

swijaya0101 11-25-2010 06:18 PM

Re: MaxCDN Content Delivery Solution?
 
It doesnt work. All images are blank.

// WCM - CDN Images
if (($type == 'T' OR $type == 'P') AND $_SERVER['HTTPS'] != 'on')
{
$image_path = str_replace('/home/mydomain/public_html/images/','',$image_path);
return str_replace('$http_location','',$image_path);
}
// / WCM - CDN Images

Anywhere I should add my cdn URL?

Stizerg 11-25-2010 09:34 PM

Re: MaxCDN Content Delivery Solution?
 
Yes, you shoud

// WCM - CDN Images
if (($type == 'T' OR $type == 'P') AND $_SERVER['HTTPS'] != 'on')
{
$image_path = str_replace('/home/mydomain/public_html/images/','your_cdn_address',$image_path);
return str_replace('$http_location','',$image_path);
}
// / WCM - CDN Images

erone123 12-29-2010 09:56 PM

MaxCDN Content Delivery Solution?
 
Thanks I tried it out about a month ago and it seems to be working quite well.

On our 4.1.x I did notice one thing:
1 - The Detail Images are not being cached, so I added "OR $type == 'D'" and My server load went way up it was hitting
Last 1 minute 5.68
Last 5 minutes 17.62
Last 15 minutes 24.81

Below is the Code I used, Not sure what to do next?

#// include/func/func.files.php - WCM - CDN Product Images
if (($type == 'T' OR $type == 'D' OR $type == 'P') AND $_SERVER['HTTPS'] != 'on')
{
$image_path = str_replace('/var/www/vhosts/mysite/httpdocs/images/','http://netdna.mysite.com/images/',$image_path);
return str_replace('$http_location','',$image_path);
}
#// / WCM - CDN Product Images

Any suggestions?

Stizerg 12-29-2010 11:12 PM

Re: MaxCDN Content Delivery Solution?
 
Sorry, I didn't get it. What's wrong?

erone123 12-31-2010 08:36 AM

Re: MaxCDN Content Delivery Solution?
 
The detail images are being cached by MaxCDN,when I added "OR $type == 'D'" to your code Below is the example.
(($type == 'T' OR $type == 'D' OR $type == 'P') AND $_SERVER['HTTPS'] != 'on')

When I added this my server load goes high which makes the website really slow or time out.

How do I get the Detail images $type == 'D' to work with with your code with out getting the high server load or time out.

Stizerg 01-01-2011 04:16 PM

Re: MaxCDN Content Delivery Solution?
 
Can you make a screenshot of FireBug's 'Net' tab?

Normally it should not happen, becouse this code only replace image address. Is there any other modifications related to detailed images?


All times are GMT -8. The time now is 07:54 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.