osCmax v2.5 User Manual
Results 1 to 10 of 10

Hosting product images (and other assets) on subdomains?

This is a discussion on Hosting product images (and other assets) on subdomains? within the osCmax v2 Customization/Mods forums, part of the osCmax v2.0 Forums category; Hi everyone. First off, I apologize if this has been answered elsewhere. I've searched this forum, the osCommerce forum, and ...

      
  1. #1
    New Member SpongeMaximus's Avatar
    Join Date
    Jan 2010
    Location
    New York
    Posts
    11
    Rep Power
    0


    Default Hosting product images (and other assets) on subdomains?

    Hi everyone. First off, I apologize if this has been answered elsewhere. I've searched this forum, the osCommerce forum, and even some ZenCart forums, but haven't been able to find the explicit instructions that I'm looking for.

    I have an osCmax 2.0.25 store, and I'm looking for a way to host my product images on a subdomain (images.mystore.com) to help improve page speed. In the future I'd like to move other assets (java, css, etc.) to their own respective subdomains, but I'd like to start with just product images. From what I've read, this is entirely possible, and some people have mentioned that they've done it, but I haven't been able to find out exactly how.

    Can anyone tell me if it involves changing the DIR_WS_IMAGES definition in includes/configure.php, or if it requires an .htaccess change, or... ?

    Any help would be greatly appreciated!

  2. #2
    osCMax Development Team
    ridexbuilder's Avatar
    Join Date
    Jul 2008
    Location
    Haggisland
    Posts
    3,014
    Rep Power
    36


    Post Re: Hosting product images (and other assets) on subdomains?

    Don't believe everything that you read.
    Given that a subdomain is (normally) just a pointer to a subdirectory, then how will this improve performance? Unless separated onto another server with high speed infrastructure, you're barking up the wrong tree. (Larger benefits are likely to be gained by moving SQL server instead)

    Since 'Max 2.0.25, I've introduced single-level subdirectory image storage. This can help where you have a substantial number of product images, say 300+. You can have individual image directories for main categories, for example, or some other means of splitting them up.
    What makes the largest improvement is to utilise the 'Max image features correctly - there should be no product images in catalog/images, only small ones in catalog/images/thumbs and larger ones in catalog/images/images_big. THE major cause of slow speed is people keeping with the default osCommerce method of resizing catalog/images in the browser.
    (On sites that I've worked on, I also use a catalog/images/extra directory, for those miscellaneous images that 'adorn' websites.)
    Image handling is further enhanced in 'Max 2.5 by having three images sizes.

    Re: java, css etc. there has been changes to the locations of these files. Rather than even thinking about subdomains, there are ways to minimise the impact on page speed. This has also been addressed by the development team.

    Without empirical values from you with regards to your site, including a URL to look at, any real facts on improving speed is hypothetical.
    Last edited by ridexbuilder; 03-22-2011 at 07:54 AM. Reason: All IMO, of course ;-)
    Hosting plans with installation, configuration, contributions, support and maintenance.

  3. #3
    New Member SpongeMaximus's Avatar
    Join Date
    Jan 2010
    Location
    New York
    Posts
    11
    Rep Power
    0


    Default Re: Hosting product images (and other assets) on subdomains?

    Thanks for the reply! To address some of your points:

    As far as some things I've already done in an effort to improve page speed... I've already merged and minified all java and css where I can, and the site uses phpThumb to auto-create small thumbnails of product images upon product creation or editing. Thumbnails go in images/tn, and full-size images go in images/images_big, so that should all be OK. I also use optimized CSS sprites for most of the little buttons, menu headers, etc. that appear throughout the site. The store that I want to try subdomains on is unfortunately still in development and is usually set to Down for Maintenance, so I'm sorry that I can't provide a URL, at least not yet. But I do appreciate your reply!

    The main reason for my wanting to try subdomains for images and other assets is outlined here, which basically says that serving resources from two (or more, up to a point) different hostnames increases parallelization of downloads and therefore decreases the overall load time of a page in a browser, which is limited to a certain number of parallel downloads per hostname. Given that I've already done much of what can be done to improve page speed, I wanted to give it a try.

    When I run Firebug's Page Speed analyzer on the front page of the store, the only thing that comes back as a real red-flag "you should fix this" item is the suggestion that I paralellize downloads across hostnames. Shrug?

    When you say "Re: java, css etc. there has been changes to the locations of these files," what do you mean exactly? Does osCmax's performance depend at all on the locations of a store's javascript and css files? And doesn't everyone's store have their own unique configurations and combinations of .js and .css files?

  4. #4
    New Member SpongeMaximus's Avatar
    Join Date
    Jan 2010
    Location
    New York
    Posts
    11
    Rep Power
    0


    Default Re: Hosting product images (and other assets) on subdomains?

    I left the following reply not too long after yours yesterday, but it still hasn't appeared (pending mod approval), possibly because it had a link in it. Here it is without the link:

    Thanks for the reply! To address some of your points:

    As far as some things I've already done in an effort to improve page speed... I've already merged and minified all java and css where I can, and the site uses phpThumb to auto-create small thumbnails of product images upon product creation or editing. Thumbnails go in images/tn, and full-size images go in images/images_big, so that should all be OK. I also use optimized CSS sprites for most of the little buttons, menu headers, etc. that appear throughout the site. The store that I want to try subdomains on is unfortunately still in development and is usually set to Down for Maintenance, so I'm sorry that I can't provide a URL, at least not yet. But I do appreciate your reply!

    The main reason for my wanting to try subdomains for images and other assets is outlined here [link to page on code dot google dot com explaining this], which basically says that serving resources from two (or more, up to a point) different hostnames increases parallelization of downloads and therefore decreases the overall load time of a page in a browser, which is limited to a certain number of parallel downloads per hostname. Given that I've already done much of what can be done to improve page speed, I wanted to give it a try.

    When I run Firebug's Page Speed analyzer on the front page of the store, the only thing that comes back as a real red-flag "you should fix this" item is the suggestion that I paralellize downloads across hostnames. Shrug?

    When you say "Re: java, css etc. there has been changes to the locations of these files," what do you mean exactly? Does osCmax's performance depend at all on the locations of a store's javascript and css files?

  5. #5
    osCMax Development Team
    ridexbuilder's Avatar
    Join Date
    Jul 2008
    Location
    Haggisland
    Posts
    3,014
    Rep Power
    36


    Post Re: Hosting product images (and other assets) on subdomains?

    I was just making people aware of the changes from 2.0.xx to 2.5 - a lot of the javascript and CSS have been relocated, tidying things up and more template-centric. In addition, some minification has been done and jquery is served from a CDN.

    I see where you're coming from now, with regards to parallelised downloads.
    For LARGE scale websites, Michael_S is better versed/experienced in e-commerce infrastructure matters. Most small/medium businesses will not need to go to this level of performance 'tweaking'.

    As previously eluded to/suggested, look to mySQL tuning and the general performance of your server (dedicated/shared) and its' overall load. Given the extensive use of SQL calls, this can have a dramatic impact.

    [P.S. pThumb is an integral part of 2.0.25 onwards and is used to generate the different image sizes during product uploads in Admin. It is not used in the way that the osCommerce contribution does - 'caching' - which may add to the load on the server. Images are served up in the correct size, from the original location.]
    Last edited by ridexbuilder; 03-23-2011 at 05:29 AM. Reason: pThumb detail
    Hosting plans with installation, configuration, contributions, support and maintenance.

  6. #6
    New Member SpongeMaximus's Avatar
    Join Date
    Jan 2010
    Location
    New York
    Posts
    11
    Rep Power
    0


    Default Re: Hosting product images (and other assets) on subdomains?

    Quote Originally Posted by ridexbuilder View Post
    I was just making people aware of the changes from 2.0.xx to 2.5 - a lot of the javascript and CSS have been relocated, tidying things up and more template-centric. In addition, some minification has been done and jquery is served from a CDN.
    That's excellent. I just started playing around with the 2.5 v3 beta the other day, and so far I'm finding the number of changes and improvements to be very impressive.

    Thanks again for your feedback! I'm going to look into some ways to check and possibly adjust some mySQL stuff.

    Can anyone else point me to a guide, or explain how to tweak my 2.0.25 store to serve product images from an "images.mystore.com" subdomain? I made a few guesses and tried things like making DIR_WS_IMAGES an explicit path, but no to avail.

    Edited to add: The next thing I tried (I'm really just trial-and-error guessing at this point) is messing with the tep_image function. I copied it and renamed the copy "tep_prod_image," and now I'm trying to point this new function explicitly to where the images will be on the subdomain, to test it out... still no luck.
    Last edited by SpongeMaximus; 03-24-2011 at 06:10 AM.

  7. #7
    osCMax Development Team
    ridexbuilder's Avatar
    Join Date
    Jul 2008
    Location
    Haggisland
    Posts
    3,014
    Rep Power
    36


    Post Re: Hosting product images (and other assets) on subdomains?

    I've done a quick bit of reading on this...

    • Try creating a CNAME entry with cookies.yourdomain.name, then set the cookie domain to this in configure.php (untested). This in theory, should prevent coofies being served up for all pages.
    • In referencing images at another location (domain/subdomain), you will need to test whether the originating page is being served via https. If it is then you will require an SSL for the images (sub)domain, otherwise the customer will see non-SSL warnings. (A key reason why elements are referenced relative, not absolute).
    An interesting bit of side-tracking, whilst doing other stuff. C'mon community, let's get more input...


    EJ
    Hosting plans with installation, configuration, contributions, support and maintenance.

  8. #8
    osCMax Development Team
    pgmarshall's Avatar
    Join Date
    Feb 2009
    Location
    London
    Posts
    2,678
    Rep Power
    49


    Default Re: Hosting product images (and other assets) on subdomains?

    In the tep_image function in catalog/includes/functions/html_output.php you could try something like:

    Code:
    function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') {
    
      $src = str_replace(HTTP_SERVER . DIR_WS_HTTP_CATALOG . DIR_WS_IMAGES, 'full_path_to_your_alternative_server', $src);
    
      Then leave the rest of the function alone.
    I have not tried this but the logic is to simply string replace the bit before the image name with a new server path. I have guessed at what the full path might be so you may have to tweak this yourself.

    You could even wrap it in a file_exists to check one server ... if it doesn't find it then it tries the other ... which would allow you to have the icons, store logo, etc. on one server and all the product image on the other.

    Regards,
    pgmarshall
    _______________________________

  9. #9
    osCMax Development Team
    ridexbuilder's Avatar
    Join Date
    Jul 2008
    Location
    Haggisland
    Posts
    3,014
    Rep Power
    36


    Thumbs up Re: Hosting product images (and other assets) on subdomains?

    Cool, PGM. This could form the basis of the test for https.
    Hosting plans with installation, configuration, contributions, support and maintenance.

  10. #10
    New Member SpongeMaximus's Avatar
    Join Date
    Jan 2010
    Location
    New York
    Posts
    11
    Rep Power
    0


    Default Re: Hosting product images (and other assets) on subdomains?

    Thanks, PGM... this looks very promising. I'm trying slight variations on the code you suggested, seeing if I can get it to pick up the thumbnails in their new location. Figuring out file paths can be a pain sometimes. Thanks again for your suggestion!

    Oh, and as far as https stuff, I do have a wildcard SSL set up on the server, which I understand is supposed to cover things served from subdomains as well.
    Last edited by SpongeMaximus; 03-24-2011 at 10:42 AM. Reason: https / wildcard SSL

Similar Threads

  1. Protect Images with Unlimited Images Per Product
    By michael_s in forum New osCommerce Contributions
    Replies: 0
    Last Post: 11-12-2010, 04:53 PM
  2. Protect Images with Unlimited Images Per Product
    By michael_s in forum New osCommerce Contributions
    Replies: 0
    Last Post: 09-09-2010, 03:10 PM
  3. Protect Images with Unlimited Images Per Product
    By michael_s in forum New osCommerce Contributions
    Replies: 0
    Last Post: 07-29-2010, 11:00 AM
  4. Are big images and extra images deleted upon product deletion?
    By gcf in forum osCMax v2 Features Discussion
    Replies: 1
    Last Post: 05-02-2010, 07:25 AM
  5. SSL issue with SubDomains
    By driwashsolutions in forum osCmax v2 Installation issues
    Replies: 3
    Last Post: 07-05-2005, 04:00 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •