Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

MAX cdn

 
Reply
   X-Cart forums > X-Cart 4 > Third Party Add-Ons for X-Cart 4
 
Thread Tools
  #41  
Old 01-13-2013, 08:00 AM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: MAX cdn

Sorry to keep posting -- hoping someone jumps in on this...

I was not able to get the detailed images (colorbox) working.

I tried editing these files, using the smarty 'replace' command as used elsewhere:

/common_files/modules/Detailed_Product_Images/product_images.tpl
/common_files/modules/Detailed_Product_Images/colorbox_image.tpl
/common_files/modules/Detailed_Product_Images/popup_image.tpl

and replaced

{$i.image_url|amp}

with
Code:
{$i.image_url|amp|replace:'www.domain.com':'cdn.domain.com'}
...and that was a big old fail. The images are not served from the cdn. Hmm...

Maybe this needs a php solution after all?
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #42  
Old 01-13-2013, 08:16 AM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: MAX cdn

OK -- another roadblock:

Images that are hard coded into the product description...

Since you can't use {$AltImagesDir} in the product description, I use a dedicated directory for all images that need to be hardcoded for the product description:

/product-images/

So I need to figure out how to get all of these images from the product description to the CDN

I guess it's gonna have to be the good old, <img src="http://cdn.domain.com/product-images/image.jpg" />, right? Fortunately, I only have 20 product pages - and only 8 needed edits. Took 5 minutes. And these pages now load faster. Just like that.

3 steps forward, 2 steps back.
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #43  
Old 01-13-2013, 09:35 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: MAX cdn

Quote:
Originally Posted by carpeperdiem
Since you can't use {$AltImagesDir} in the product description...
I haven't tested this at all, but could you use eval to include the variable?
Like in this thread: http://forum.x-cart.com/showthread.php?t=21027&highlight=eval
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #44  
Old 01-13-2013, 09:42 AM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: MAX cdn

Quote:
Originally Posted by totaltec
I haven't tested this at all, but could you use eval to include the variable?

Thanks, Mike -- but I am not using variables here... just a path to an image directory. And there is no need to make a var out of this since I hard coded the path initially.
Thanks for the suggestion though... The more I edit templates integrating the CDN, the more I realize this is a much needed part of the core code that should be a checkbox and a one line text input.

Once you see the metrics comparing stock xcart vs. xcart with CDN, your jaw will drop. You can spend days (weeks) optimizing php code and templates, or you can spend minutes turning on the CDN. It's that big a deal. In my case more than 50% reduction in page load time!
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote

The following user thanks carpeperdiem for this useful post:
totaltec (01-13-2013)
  #45  
Old 01-13-2013, 12:31 PM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: MAX cdn

What is the best practice for MaxCDN settings:

SEO robots.txt -- disabled? But is that logical? I want my images indexed. But if the URL for the image is a cache file, that's not good...

Set Default Cache Time: 7 days? Longer? Product images are static and rarely change. Homepage banner images can change daily, or not. Is there a best practice for this?

What does Google see when it finds cached images?

Thinking out loud.
Thanks,
J
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #46  
Old 01-14-2013, 12:48 PM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: MAX cdn

Still trying to solve this -- anyone have any ideas?

Quote:
Originally Posted by carpeperdiem
Slight problem here that hopefully someone can help solve...

This code works -- until you go https at checkout, and then it's a mess (css disappears).

I tried the following, but this cased a server error:

PHP Code:
/* MaxCDN edit - comment out next two lines
            ? '<script type="text/javascript" src="' . $cacheWebFile . '"></script>'
            : '<link rel="stylesheet" type="text/css" href="' . $cacheWebFile . '" />';
*/
// Then insert the following:
if ($_SERVER['HTTPS'] != 'on') {
            ? 
'<script type="text/javascript" src="' str_replace("www.domain.com","cdn.domain.com",$cacheWebFile) . '"></script>'
            
'<link rel="stylesheet" type="text/css" href="' str_replace("www.domain.com","cdn.domain.com",$cacheWebFile) . '" />';
}
else
{
            ? 
'<script type="text/javascript" src="' $cacheWebFile '"></script>'
            
'<link rel="stylesheet" type="text/css" href="' $cacheWebFile '" />';


Hmm... must be my php syntax, right? Isn't this how to do an if? What am I missing? Thanks!
Jeremy
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #47  
Old 01-14-2013, 04:02 PM
 
cellswag cellswag is offline
 

Member
  
Join Date: Jul 2010
Posts: 13
 

Default Re: MAX cdn

What about getting the product images to show up using the CDN in the root images folder T and P?
__________________
Version 4.5.4
Reply With Quote
  #48  
Old 01-14-2013, 04:10 PM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: MAX cdn

Quote:
Originally Posted by cellswag
What about getting the product images to show up using the CDN in the root images folder T and P?

For the T thumbs, I followed the suggestion from post #31

Then added the https code as follows:

I used this code for the Thumbs (trapping for https):

Code:
FILE: /skin/common_files/product_thumbnail.tpl FIND: {$tmbn_url|amp} REPLACE WITH: {* MaxCDN edit - comment out next line *} {* {$tmbn_url|amp} *} {if $smarty.server.HTTPS ne "on"} {$tmbn_url|amp|replace:'www.domain.com':'cdn.domain.com'} {else} {$tmbn_url|amp} {/if} {* END MaxCDN edit *}
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
  #49  
Old 01-14-2013, 04:14 PM
 
cellswag cellswag is offline
 

Member
  
Join Date: Jul 2010
Posts: 13
 

Default Re: MAX cdn

Quote:
Originally Posted by carpeperdiem
For the T thumbs, I followed the suggestion from post #31

Then added the https code as follows:

I used this code for the Thumbs (trapping for https):

Code:
FILE: /skin/common_files/product_thumbnail.tpl FIND: {$tmbn_url|amp} REPLACE WITH: {* MaxCDN edit - comment out next line *} {* {$tmbn_url|amp} *} {if $smarty.server.HTTPS ne "on"} {$tmbn_url|amp|replace:'www.domain.com':'cdn.domain.com'} {else} {$tmbn_url|amp} {/if} {* END MaxCDN edit *}

I have that set, but its not showing. For Thumbnails, category images, or detailed. Anything else im missing?
__________________
Version 4.5.4
Reply With Quote
  #50  
Old 01-14-2013, 04:22 PM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: MAX cdn

Quote:
Originally Posted by cellswag
I have that set, but its not showing. For Thumbnails, category images, or detailed. Anything else im missing?

Did you set the CNAME record in cPanel? Are you using cdn.domain.com as an alias for "company.company.netdna-cdn.com" ?

If you have it set correctly, if you view your page source, almost immediately, what was:
Code:
<img src="http://www.domain.com/images/T/xctmp0O7ydz.jpg"
becomes
Code:
<img src="http://cdn.domain.com/images/T/xctmp0O7ydz.jpg"

Are you seeing anything sent to the cdn?
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Third Party Add-Ons for X-Cart 4



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

   

 
X-Cart forums © 2001-2020