Magento CDN Setup on Local Server by Subdomain

apachecdnmultistoreperformanceserver-setup

While reading up on some Magento I was again attracked to the following: How can I set-up a Magento CDN on local server by subdomain? [also see attached images]

I am envisioning to set-up cdn.mymagentoserver.com, have it point to the same public_html folder as www.mymagentoserver.com and change the media directories as shown below.

Question:

  1. how does one set-up a subdomain like described?

Additional to think about

  • would it also work for all domains of a multistore?
  • how about when I add https in the future? Wouldn't the images be coming from an unsafe domain if I had a SAN certificate? or would I just add the subdomain too
  • Is this all worth it?

enter image description here

Best Answer

It's possible, but by definition not a CDN (content delivery network)

There are still advantages though: if you set up the cookie domain in Magento to www.example.com, cookies will not be sent with requests to static.example.com, making the requests a bit more lightweight and faster (also: more cachable). The cookie domain can be set up in the same config section as the base urls. If your base URL is like example.com without "www", use example.com and pay attention that it's not prepended by a dot (because .example.com would include all subdomains)

Screenshot

Another argument is that browsers limit the number of parallel requests per domain, so having a second domain can speed up total page load as well. But this is not so relevant today anymore, so take it with a grain of salt and especially don't start to distribute the requests over more than two or three domains.

The success of domain sharding can be mitigated if it’s done incorrectly. It’s important to keep these guidelines in mind.

  1. It’s best to shard across only two domains. You can test larger values, but previous tests show two to be the optimal choice.
  2. Make sure that the sharding logic is consistent for each resource. You don’t want a single resource, say main.js, to flip-flop between domain1 and domain2.
  3. You don’t need to setup different servers for each domain – just create CNAMEs. The browser doesn’t care about the final IP address – it only cares that the hostnames are different.

Source: http://www.stevesouders.com/blog/2013/09/05/domain-sharding-revisited/

As for your question how to set it up: ask your hoster. They can either do it for you or tell you how to do it. It's not exactly the same on every system.

Related Topic