So today, I was working on an older x-cart site after implementing some of the previous CDN / static domain hacks, I looked at the product images which were being displayed via the main domain. Because CleanURLs were enabled, I couldn’t just edit the thumbnail template file but rather edit the CleanURL creator function. So here’s my edits for X-Cart 4.3 and xcart 4.5.
Edit /func/func.files.php
approx. line 254 (xcart 4.3) or line 374 (xcart 4.5)
from:
return $current_location.str_replace(DIRECTORY_SEPARATOR, "/", substr($image_path, strlen(preg_replace("/".preg_quote(DIRECTORY_SEPARATOR, "/")."$/S", "", $xcart_dir))));
to:
if ($_SERVER['HTTPS'] != 'on') { return "http://cdn.domain.tld".str_replace(DIRECTORY_SEPARATOR, "/", substr($image_path, strlen(preg_replace("/".preg_quote(DIRECTORY_SEPARATOR, "/")."$/S", "", $xcart_dir)))); } else { return $current_location.str_replace(DIRECTORY_SEPARATOR, "/", substr($image_path, strlen(preg_replace("/".preg_quote(DIRECTORY_SEPARATOR, "/")."$/S", "", $xcart_dir)))); }
The issue that needs to be then addressed is how to balance the previous edits with this one over x number of domains so the file requests can be parallel and not blocking, after looking, putting javascripts and css files on one domain, catalogue images on anotherand possibly any remaining requests manually written in via a third? in this scenario, {$skin}/{$alt_skinDir} and {$images}/{$alt_imagesDir} (being remembered from memory) could be over two domains and then the catalogue images on the third.
Ideally you want to even out the requests (no less than 5 to 10 requests) over the domains with upto 3 sub-domains maximum to reduce the number of DNS lookups but depending on what’s being serviced and checkign with online tools will help test which is the best layout.