Faster Page Loads with Subdomains for Images & Uploads
Re: Faster Page Loads with Subdomains for Images & Uploads
The rewrite is more simple then to right it all to the root... all it does is say if a .jpg just remove the www and replace with what have you...
so
http://www.uisge-beatha.eu/uploads/images/MD2020.jpg
would be
http://image.uisge-beatha.eu/uploads/images/MD2020.jpg
Now I have no idea on your set up... but with the .htaccess route all you should do is in the dns create the alias to point to the root.. match you www record, do all the normal alias step you do just point it all to the root. And that is it... if you tired any of the other routes below then this will not work...
HTH - Cheers Jeremy
so
http://www.uisge-beatha.eu/uploads/images/MD2020.jpg
would be
http://image.uisge-beatha.eu/uploads/images/MD2020.jpg
Now I have no idea on your set up... but with the .htaccess route all you should do is in the dns create the alias to point to the root.. match you www record, do all the normal alias step you do just point it all to the root. And that is it... if you tired any of the other routes below then this will not work...
HTH - Cheers Jeremy
Re: Symlink works best!
Got it working, after a long hassle.kendo451 wrote:
I did find that image manager generates links with an extra http://domain.com on the front, so until that is fixed you might NOT want to change the path for images in config.php.
.htaccess
Code: Select all
Order deny,allow
RewriteEngine on
RewriteCond %{REQUEST_URI} \.(ico|gif|jpg|jpeg|png|flv|pdf|mp3|wav|js|css|kml|xml)$
RewriteCond %{HTTP_HOST} ^www\.image\. [NC]
RewriteRule .* http://www.uisge-beatha.eu/uploads/images%{REQUEST_URI} [R=301,L]
Code: Select all
#Default path and URL for uploaded images in the image manager
#$config['image_uploads_path'] = '/home/efacti/public_html/uisge-beatha.eu/uploads/images';
#$config['image_uploads_url'] = $config['root_url'] . '/uploads/images';
$config['image_uploads_path'] = '/home/efacti/public_html/image';
$config['image_uploads_url'] = 'http://www.image.uisge-beatha.eu';
Gregor
Last edited by Gregor on Wed Dec 30, 2009 9:01 am, edited 1 time in total.
Jeremy, does your solution actually work in the browser?
Hi Jeremy,
Your Apache Mod-Rewrite solution is definitely the simplest way to get the images to come from a subdomain.
The question is, does it work in the browser? Obviously you can see it in the browser, but that isn't what I mean.
The reason we do this trick is that when the browser parses an HTML page, it will link to up to four domains to pull images, scripts, and css files, but pulls them sequentially from any one domain.
So by linking to four domains to get the external page elements, you can get four simultaneous connections and make the page load 4 x faster.
Your solution takes links to the same domain and re-writes the url to the subdomain. But I suspect that at this point the browser has already made its list, and the fact that a url gets re-written isn't going to cause it to jump to the next file on the list.
Have you tested this to see if it actually generates the same performance improvement as using a real subdomain link?
Thanks,
Ken
Your Apache Mod-Rewrite solution is definitely the simplest way to get the images to come from a subdomain.
The question is, does it work in the browser? Obviously you can see it in the browser, but that isn't what I mean.
The reason we do this trick is that when the browser parses an HTML page, it will link to up to four domains to pull images, scripts, and css files, but pulls them sequentially from any one domain.
So by linking to four domains to get the external page elements, you can get four simultaneous connections and make the page load 4 x faster.
Your solution takes links to the same domain and re-writes the url to the subdomain. But I suspect that at this point the browser has already made its list, and the fact that a url gets re-written isn't going to cause it to jump to the next file on the list.
Have you tested this to see if it actually generates the same performance improvement as using a real subdomain link?
Thanks,
Ken
Re: Faster Page Loads with Subdomains for Images & Uploads
here you be the judge... ;)
http://www.digitalbarn.tv/
and a net shot of one of my test sites is attached.. and yes I do see a gain.. but this is only one of many tricks you could be doing... as you see I have the css and images inline.. now this was the quick test, I also have the components pointed to the subdomain to help avoid any delays which null out the gain.
So if you look at the net there is no redirects... because from the start I planned for the subdomains..
I'd have to ask to show other sites but overall it's just one of many things to make it snappy...
Best suggestion is to test for yourself.. see if the server your on will some the gain...
Hope this helps..
Cheers
note I have 8 there inline...
http://www.digitalbarn.tv/
and a net shot of one of my test sites is attached.. and yes I do see a gain.. but this is only one of many tricks you could be doing... as you see I have the css and images inline.. now this was the quick test, I also have the components pointed to the subdomain to help avoid any delays which null out the gain.
So if you look at the net there is no redirects... because from the start I planned for the subdomains..
I'd have to ask to show other sites but overall it's just one of many things to make it snappy...
Best suggestion is to test for yourself.. see if the server your on will some the gain...
Hope this helps..
Cheers
note I have 8 there inline...
Re: Faster Page Loads with Subdomains for Images & Uploads
Here is another one.. both of these are not as uptodate with the practices I do now but as you can see it's loaded right, also, thou Google is throwing a cookie on it do to the way I set that up there is no other cookie on there... so it did its job of
0-rewrite time (because I'm pointing to the right subdomain)
0-cookie bits from CMSMS
18- inline loads till the js which I'm sure you know that css files hold up imgs which is not happening here, and there is no way to parallel js scripts and is why you should be puting all js at the bottom of you html...
hope that helps...
cheers
0-rewrite time (because I'm pointing to the right subdomain)
0-cookie bits from CMSMS
18- inline loads till the js which I'm sure you know that css files hold up imgs which is not happening here, and there is no way to parallel js scripts and is why you should be puting all js at the bottom of you html...
hope that helps...
cheers
Re: Faster Page Loads with Subdomains for Images & Uploads
Ok, now I realize that my criticism was invalid. You are using the www.subdomain.domain.com in the links on the actual html page, so the browser still sees each subdomain as a unique domain.
Ken
Ken
Re: Faster Page Loads with Subdomains for Images & Uploads
Well it's subdomain.domain.tdl but yes pointing right ate the location save the redirect from occurring.. Since most of my module account for this it's not an issue there... and other mods I have canned the parts that need to deal with this. Mostly just a simple |replace type stuff...
Criticism makes the code strong like bull...
Cheers
Jeremy
Criticism makes the code strong like bull...

Cheers
Jeremy
Re: Faster Page Loads with Subdomains for Images & Uploads
Ok, Jeremy, now you're confusing me.
I thought you were recommending the .htaccess - only method as the best. But now you're saying you actually are pointing the subdomains at the directories using symlinks so they don't have to be redirected by .htaccess ?
I thought you were recommending the .htaccess - only method as the best. But now you're saying you actually are pointing the subdomains at the directories using symlinks so they don't have to be redirected by .htaccess ?
Re: Faster Page Loads with Subdomains for Images & Uploads
No.. the elements.. I point thosekendo451 wrote: Ok, Jeremy, now you're confusing me.
I thought you were recommending the .htaccess - only method as the best. But now you're saying you actually are pointing the subdomains at the directories using symlinks so they don't have to be redirected by .htaccess ?

yeah I see how that could have been read that way .. I use .htaccess and point all dns alias' to the root. That is what I do

Sorry If I was unclear, slip of wording... -J
Re: Faster Page Loads with Subdomains for Images & Uploads
Jeremy, do I understand you correct that as soon as you have a site running for a while, there is no other way than moving all image/pictures to the subdomains (as shown in my previous post) and correcting all (!) links inside the cms to the subdomain?
Gregor
Gregor
Re: Faster Page Loads with Subdomains for Images & Uploads
Ok I hope I understood you question rightGregor wrote: Jeremy, do I understand you correct that as soon as you have a site running for a while, there is no other way than moving all image/pictures to the subdomains (as shown in my previous post) and correcting all (!) links inside the cms to the subdomain?
Gregor

In theory for the 0 lose of potential performance on both the server and the client during rendering of the dom, yes you would want to start off with the right location of the component. Why put www when it’s media… this can be handled with out really any time spent.
What I did was look at my gain verse lose… On most servers this is what I see
Gains:-0 cookie bits,
-parallel downloads,
-Server does no rewrite or redirect
-reduced response and receiving times… I usually see 25-100ms savings per componet
Lose:-You must be strict on practice so your clients editing don’t complain
-Server processes for |replaces where a mod has not provided the subdomain override.
This is what I do… but to be honest I am always trying something to see if I can find a better way.. You don’t have to do this.. But when it’s put in your style of construction it adds little in the way of time so for me there is no reason not to.
My2Cents here … hope this helps show what I’m thinking and doing

Cheers
Jeremy
Re: Faster Page Loads with Subdomains for Images & Uploads
Thanks Jeremy. This supports the thoughts I had on this one.
An improvement I can make, is to put the js-files and de css-files onto a subdomain. Allthough I have to check/see/measure if putting the cs-files on a subdomain would be a faster load than useing the {stylesheet} tag.
Any suggestions for improvement of the load time, are more than welcome
Gregor
An improvement I can make, is to put the js-files and de css-files onto a subdomain. Allthough I have to check/see/measure if putting the cs-files on a subdomain would be a faster load than useing the {stylesheet} tag.
Any suggestions for improvement of the load time, are more than welcome

Gregor
Re: Faster Page Loads with Subdomains for Images & Uploads
Gregor, you could keep the stylesheet tag, and just change a rewrite rule so that it triggers if stylesheet.php is contained in the url, and the url begins with css.
Re: Faster Page Loads with Subdomains for Images & Uploads
Thanks for your quick reply. I will see if I understand the way the css-files are loaded so I can change it as you suggest. What is crossing my mind, is that they are loaded into the database, if I'm correct on my setup. All stylesheets are placed in the folder 'stylesheet'.
Gregor
Code: Select all
{static_stylesheet}
<!-- This is how all the stylesheets attached to this template are linked to -->
{cms_selflink dir="start" rellink=1}
{cms_selflink dir="prev" rellink=1}
{cms_selflink dir="next" rellink=1}
<!-- Relational links for interconnections between pages, good for accessibility and Search Engine Optmization -->
Last edited by Gregor on Thu Feb 11, 2010 6:51 am, edited 1 time in total.
Re: Faster Page Loads with Subdomains for Images & Uploads
Did some more work on this last night.
If you want the stylesheets to use your congifuration, then you need to edit the function.stylesheets.php plugin in the plugins directory.
I am making a copy of the plugin, and renaming it so that it won't be overwritten when I upgrade CMSMS.
So the new one is function.css_stylesheets.php and I change the function name to _cms_stylesheets inside.
I haven't finished this yet, but I'll post it here if/when I get it working.
If you want the stylesheets to use your congifuration, then you need to edit the function.stylesheets.php plugin in the plugins directory.
I am making a copy of the plugin, and renaming it so that it won't be overwritten when I upgrade CMSMS.
So the new one is function.css_stylesheets.php and I change the function name to _cms_stylesheets inside.
I haven't finished this yet, but I'll post it here if/when I get it working.