I currently load all my files on one domain.

I thought it would be better to load all js, media and css content from a subdomain, like:


Does anybody know if this improve the speed positive?

  • yes ,sure it improve the site speed...But you need upload file js and css,media files to your base site magent dir
    – Amit Bera
    Jun 15, 2015 at 14:10
  • dont forget that you need to properly configure cache and ignore cookies...
    – user2857
    Jun 15, 2015 at 17:20

2 Answers 2


You can achieve this by creating a subdomain on your server configuration and linking the root folder of the new subdomain to the js/css folders you want to server from there with something like

ln -s /var/www/html/domain.com/magento/media /var/www/html/domain.com/cdn/media for skin and js folders.

This guide shows you how to achieve this on nginx, it should be pretty straightforward with apache too.

You can add some expire headers for the resources in the vhost creation or in a .htacess too.

Then go to System > Configuration > Web > Unsecure and change {{unsecure_base_url}} to the new subdomain you created for all the resources you want to server from your local CDN. Same for Secure urls.

  • why does he have to do all this ?? creating a fake CDN is just pointing your subdomain to the same ip address as your main domain... nothing else, and change magento media url to http://media.domain.com/media. for any advanced CDN he needs to run any separate vps...
    – user2857
    Jun 15, 2015 at 17:17
  • and your guide has no caching rules
    – user2857
    Jun 15, 2015 at 17:21
  • @ADM create another answer or edit mine's if you think you can improve it.
    – mbalparda
    Jun 15, 2015 at 17:24

@ADM - because browsers will limit the amount of requests coming from a single domain. With more domains, the browser will accept more connections hense making for a speedier overall render time

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.