We are about to implement a custom CDN for images but there are two different options I am thinking (I work in a very small company that I am the R&D manager with only one employ in the department) to try for SEO and I thought to ask for ideas to what is best. First of all I must make a small introduction that I am referring to several small (more than 200) and few large (more than 20) eShops that we serve with the arrangement that they don't own the software + code , but the data (+images ,+what ever) and the maintenance. Many of those are in https but I couldn't have the option to make them pay for wildcard https certificate in sub domains , an external CDN service or even few https certificates in some of their subdomains (most of them wouldn't even understand why I try to make their sites even faster since they are already faster from the rest).

How to do it is not a problem for us , the way our apps work ,makes it easy. The issue is how to do it without affecting the SEO that is already good , many of those site receive a great amount of traffic from image results in Google and we wouldn't like to alter anything in that . So here are the two options.

First option (client side). Detect if the request is from Google bot and if it isn't after DOM loaded alter all img src in a certain pattern with the CDN address. Notice that those apps work with AJAX || WebSockets to retrieve content from other pages (+change the URL , in a way that if that URL page is retrieved directly will have the same result) , so the gain isn't just for the first page. The bad think about that is that we made a lot of effort to serve the same content for Google bot and for users through Ajax || WebSockets procedure , and that will alternate that. More over I am not sure if Google bots could recognize that and if they do would red flag those sites even if the image contents are the same.

Second option (server side). Serve the CDN address of images from server side. When the browser request the image if the referral header isn't from the site's domain return a 301 permanent redirection to the image in the site domain. This is one more check server side but not too much since already the images are served though an internal process (repository out of www - public_html + watermarks + URL's of images file names that are in UTF-8 + Etags + more). The question here is that I don't know if Google bot might send a referral that is from the site's domain or if will follow the 301 and index the image with the same efficiency .

I really would like to read your opinions about those two options or any alternative that we haven't thought yet.

In second option I tested it and found out that even if some Google bots don't send referrer certainly send a string that contains “bot” (case insensitive) in HTTP_USER_AGENT (e.g. in $_SERVER[“HTTP_USER_AGENT ”] in PHP . So the recognition to serve a 301 to the image in the original domain of the site could be done to that criteria. The question remains if Google will index those images in the same way as if it were the original URL.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.