Serving images from another hostname or Apache overload for the rewrites?
-
We are trying to improve further the speed of some sites with older HTML in order as well to obtain better SEO results. We have now applied some minify measures, combined html, css etc. We use a small virtualized infrastructure and we've always wanted to use a light + standar http server configuration so the first one can serve images and static contents vs the other one php, rewrites, etc. We can easily do that now with a VM using the same files and conf of vhosts (bind mounts) on apache but with hardly any modules loaded. This means the light httpd will have smaller fingerprint that would allow us to serve more and quicker, have more minSpareServer running, etc. So, as browsers benefit from loading static content from different hostnames as well, we've thought about building a rewrite rule on our main server (http://main.com) to "redirect" all images and css *.jpg, *.gif, *.css etc to the same at say http://cdn.main.com thus the browser being able to have more connections. The question is, assuming we have a very complex rewrite ruleset already (we manually manipulate many old URLs for SEO) will it be worth? I mean will the additional load of main's apache to have to redirect http://main.com/image.jpg (I understand we'll have to do a 301) to http://cdn.main.com/image.jpg + then http://cdn.main.com having to serve it, be larger than the gain we would be archiving on the browser? Could the excess of 301s of all images on a page be penalized by google? How do large companies work this out, does the original code already include images linked from the cdn with absolute paths? EDIT Just to clarify, our concern is not to do so much with server performance or bandwith. We could obviously employ an external CDN server but we have plenty CPU and bandwith. Our concern is with how to have "old" sites with plenty semi-static HTML content benefiting from splitting connections for images and static content via apache without having to change the html to absolute paths (ie. image.jpg to http://cdn.main.com/image.jpg happening on the server not the code)
-
Answer:
Have you considered using Nginx as reverse proxy to serve static content? You can do this without the rewrite rules on Apache. Check out http://cnedelcu.blogspot.com/2009/09/setting-up-nginx-as-reverse-proxy-on.html for details on how this can be done. Using Nginx for load-balancing and reverse-proxying is pretty common practice in high volume/high traffic websites, so evaluate if it helps you.
Raghavendra Kidiyoor at Quora Visit the source
Other answers
A server-side redirect for these images is not likely to have the effect you intend on concurrent connections in the client browser since the html received by the browser will contain images served from the same domain. In order to achieve your intended goal, you would need to rewrite the urls in the response you serve to the client.
Travis Truman
For light serving of static content, you might want to look at something like lighttpd. You can configure it to serve out that static stuff and then proxy requests for dynamic content to your Apache server. If it's PHP which is causing headaches, you could look into mod_fcgid as a way to reduce the size of your Apache processes (so you can run more of them - and potentially make use of a different MPM).
Andy Kelk
Related Q & A:
- How to remotly debug python on my apache?Best solution by blog.jetbrains.com
- How to start Apache Solr automatically?Best solution by stackoverflow.com
- How to change server name in apache?Best solution by ehow.com
- How can I overload equal method to make different objects have same hashcode value in unordered_multimap?Best solution by Stack Overflow
- Are there any restaurants serving beef ribs near Owings Mills, MD (since Tony Roma's closed this past weekend)?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.