Have been using Google's Page Speed thingy to see what I can do to speed up my page loads. One of the suggestions is to move content to different subdomains, so for example, all css files would come from css.example.com, all images would come from img.example.com, etc. This is all to do with the way browsers queue up all the content they want to download...the more domains, the more the browser will try to download concurrently. It's also got something to do with having cookies on the domain, but that's not really important.
I was thinking of doing this via http rewrites, or hacking silverstripe, but I'm wondering if this is already supported? Also, before you tell me not to do this, as it makes no real difference, there are other reasons to do stuff to make Google like your website :)
You neither need to hack Silverstripe nor to use rewrites. Simply create a virtual host in your webserver pointing to your theme directory. Turn on gzip compression for this vhost and tweak caching headers.
Don't create a subdomain for each css, js, images folder as this would slow down things on a medium site due to the extra DNS lookups. Clearly stated in Google's Page Speed docs.
I am using Plesk for my server management.
Would creating a subdomain for the 'themes' directory do the same?
and once the themes.mysite.com domain is setup, how do we get silverstripe to use this domain when using $ThemeDir?
This shouldn't be that hard, but might require a small hack to the core.
Set up a virtual host pointing to the theme directory. Then set the constant THEMES_DIR to the fully qualified path (eg, static.example.com). This will cause Sapphire to error, as it attempts to redefine THEMES_DIR in core.php - so alter the line with: