3

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

  • To answer 'Is this all worth it' can you tell us how many requests per page you are seeing on your store? A big reason to use a CDN is to reduce request queueing enabling pages to finish loading faster. – Jonathan Hussey Sep 9 '14 at 11:45
  • 152 .................... – snh_nl Sep 9 '14 at 12:31
  • Ah right...yes I can see what you are using a CDN ;) to be honest this is really more a sysadmin type question that Magento specific so I suspect that you may get better answers elsewhere, but if you are unable to reduce the number of requests by other means (CSS/JS merging/minification, reducing images per page etc) then yes it most likely is worth it. – Jonathan Hussey Sep 9 '14 at 12:37
  • Please take your time to accept an answer if it helped you. magento.stackexchange.com/help/someone-answers – Fabian Schmengler Jul 21 '15 at 10:36
1

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.

|improve this answer|||||
2

This is extremely simple to achieve and there is absolutely value in making this change despite not using a formal CDN.

CDN's don't always improve performance for your domestic market (in some cases it will make it slower). You'll lose nothing setting up a few sub domains, and potentially gain a little.

The real advantage to using sub domains for static content is to ensure the content is served cookie free. If content doesn't have a cookie, its more cacheable (whether by a reverse proxy like Varnish or the browser itself). There's so the fact that modern browsers cannot pipeline more than a handful of requests to a single domain at once, introduce multiple domains (or sub domains) and you can suddenly increase that parallelism by a factor of however many sub domains you use.

When you consider that almost 90% of your traffic is HTTP, that means that 90% of your customers will benefit. For HTTPS, keep it simple and to a single domain - when a customer is browsing a HTTPS page, its the checkout anyway, so there's little gains to be made.

Setting it up is as simple as adding the sub domains (js/skin/media), and symlinking them to the respective folder as necessary.

Takes about 3 minutes to configure, its free, requires nothing complex, and will give instant/immediate improvements.

|improve this answer|||||
1

Take a look at CloudFlare. If you are comfortable making some DNS changes then this should be pretty easy to setup. Basically, your webserver acts as the origin server. CloudFlare then hits your server once to cache each file (on-demand). Any changes to files in Magento will require you to manually purge the CDN cache or wait for the cache expire.

To make things easier, I would recommend you keep the folder structure the same. If you want to change the folder, this shouldn't be too hard with a rewrite rule. Additional stores would just require additional CNAMES to match your additional store domains.

SSL is easy with CloudFlare if you want to use their cert. You can also use your own if you have a wild card or a separate cert for the subdomain. https://www.cloudflare.com/ssl

If you want more options, also check out AWS CloudFront. It is a little hard to setup but it is more flexible. http://aws.amazon.com/cloudfront/

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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