Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Seperate sub-domain for static content

Go to End

4 Posts   3100 Views


Community Member, 11 Posts

15 April 2010 at 10:31pm

Hi all,

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, all images would come from, 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 :)

Ronan 2.0


Community Member, 10 Posts

29 April 2010 at 8:37pm

Edited: 29/04/2010 8:38pm

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.


Community Member, 178 Posts

17 February 2011 at 1:18pm

I am using Plesk for my server management.
Would creating a subdomain for the 'themes' directory do the same?
and once the domain is setup, how do we get silverstripe to use this domain when using $ThemeDir?


Community Member, 712 Posts

17 February 2011 at 3:00pm

Edited: 17/02/2011 3:01pm

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, This will cause Sapphire to error, as it attempts to redefine THEMES_DIR in core.php - so alter the line with:

define('THEMES_DIR', 'themes');


if(!defined('THEMES_DIR')) define('THEMES_DIR', 'themes');

Be interested to hear how you go.