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, biapar, Willr, Ingo, swaiba, simon_w

Seperate sub-domain for static content


4 Posts   2194 Views


15 April 2010 at 10:31pm Community Member, 11 Posts

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


29 April 2010 at 8:37pm (Last edited: 29 April 2010 8:38pm), Community Member, 10 Posts

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.


17 February 2011 at 1:18pm Community Member, 178 Posts

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?


17 February 2011 at 3:00pm (Last edited: 17 February 2011 3:01pm), Community Member, 712 Posts

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.