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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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   3665 Views

Avatar
DJMatus23

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 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 :)

Cheers
Ronan 2.0

Avatar
netnoise

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.

Avatar
DsX

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 themes.mysite.com domain is setup, how do we get silverstripe to use this domain when using $ThemeDir?

Avatar
Hamish

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, static.example.com). 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');

To:

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

Be interested to hear how you go.