Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2010-09-01 08:04:24

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: Host textpattern images on a subdomain for speed increase

Thanks, I’ll read up on symlinks as I’ve not used them before but that sounds like a good solution to me.

Regarding cookies, I only have Google Analytics and Textpattern setting cookies on the site anyway, GA does by default set a cookie for the whole domain including subdomains but you can make it just set a cookie for the www domain only by using:

pageTracker._setDomainName("www.example.com")

And as Wet says, Textpattern does that by default for it’s cookie anyway.

Last edited by philwareham (2010-09-01 08:05:48)

Offline

#14 2010-09-02 17:33:56

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: Host textpattern images on a subdomain for speed increase

OK, this is now sorted with help form everyone here thanks. I tried symlinks but that did not work as intended, so I went down the route of changing the virtualhost DocumentRoot for the subdomain so any calls to static1.example.com are actually going to www.example.com.

So files actually never physically reside in the subdomain, only in the standard domain as normal – but as far as a browser is concerned it is pulling images from the static1.example.com/images/ and taking advantage of the parallel downloading and ‘cookielessness’.

The ‘ihu’ in the textpattern config.php is pointing to the subdomain by the way, so this only works in forthcoming TXP 4.3.0 (or the current SVN).

Last edited by philwareham (2010-09-02 17:36:45)

Offline

#15 2010-11-10 16:59:20

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: Host textpattern images on a subdomain for speed increase

Here what I’ve done:

  • created domain sub.example.com
  • deleted directory www /home/u12345/sub.example.com/www – it’s created after subdomain rises. ususally it stores all site files No need to do this – read upd in the end of post
  • ran this command in shell – ln -s /home/u12345/example.com/www/images /home/u12345/sub.example.com/www/images

After this, if you open in browser url http://sub.example.com/images/1.jpg you get 1.jpg from http://example.com/images/1.jpg

What is this command for? It creates symlink (like shortcart in Windows terminilogy) “images” in your subdomain. And when web-server opens http://sub.example.com/images/ in your subdomain, indeed you get content of another directory, which is located in your main domain http://example.com/images

All is left is to add define('ihu', 'http://sub.example.com/'); to your /textpattern/config.php

As a result your images will be load from http://sub.example.com/images/@. In my case it is http://images.mysite.com/images/ – not very beauty, but handy :)

Greate feature indeed. Will be measuring site speed rise for some days :)

UPD: Added a fix. A symlink now is placed inside sub.example.com/www/images. In first version images were reachable by url sub.example.com/1.jpg, but TXP builds urls with images dir – sub.example.com/images/1.jpg.

Last edited by the_ghost (2010-11-12 09:07:24)


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

#16 2010-11-10 17:13:49

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: Host textpattern images on a subdomain for speed increase

Don’t forget to load all other static resources like scripts or stylesheets from this domain, too.

Offline

#17 2010-11-10 17:27:18

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: Host textpattern images on a subdomain for speed increase

I would suggest optimally 2 or 3 subdomains for static resources, since modern browsers can do multiple parallelised downloads at once (though it seems over 4 at once and it starts to adversely affect the performance). On my new site (not yet launched) I serve content images (textpattern-based images) from subdomain1 and javascript, css and site styling images from subdomain2, which works great.

Remember to make minifed versions of your css and javascript too using something like YUI compressor.

I’ve managed to get my google pagespeed rating up to 97/100 so far by using a combination techniques outlined firebug pagespeed extension, the new mod_pagespeed apache module google released last week, and textpattern. It really flies now.

Last edited by philwareham (2010-11-10 17:30:27)

Offline

#18 2010-11-11 02:43:56

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: Host textpattern images on a subdomain for speed increase

@Victor/Phil – how about a nice TXP Tip for this?

Offline

#19 2010-11-11 07:43:35

TNT
Member
From: Rotterdam, Netherlands
Registered: 2006-01-06
Posts: 256
Website

Re: Host textpattern images on a subdomain for speed increase

jstubbs wrote:

@Victor/Phil – how about a nice TXP Tip for this?

+1. I understand half of the instructions, which clearly isn’t enough… ;-)


Prrrrrrrr

Offline

#20 2010-11-11 09:38:18

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: Host textpattern images on a subdomain for speed increase

OK, I’ll write a TXP Tip when I get a spare few minutes, although some of this is based on the user having an apache web server and the permissions to add subdomains.

Offline

#21 2010-11-11 15:09:16

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: Host textpattern images on a subdomain for speed increase

Here is the TXP Tip covering this topic.

Let me know if you find any glaring errors within it.

Offline

#22 2010-11-12 09:16:59

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: Host textpattern images on a subdomain for speed increase

Added a little comment what does symlink means – i think now it’s pretty clear to understand.


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

#23 2010-11-12 18:38:44

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
Website

Re: Host textpattern images on a subdomain for speed increase

Thanks Phil, Victor, everybody, I’ve caught the speed bug too! This looks like another great addition to the txp speed up tips! After getting it all working, I posted a comment on TXPTIPS, Phil, using Victor’s symbolic link method instead of DocumentRoot and also using rvm_css. Just one other thing not mentioned: I can no longer use <txp:site_url /> to point to folders on subdomains, so I use <txp:output form form="speedurl" /> now. Perhaps there’s a better way?


BB6 Band My band
Gud One My blog

Offline

#24 2010-11-13 12:16:44

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
Website

Re: Host textpattern images on a subdomain for speed increase

I noticed in .htaccess there’s a line: #Options +FollowSymLinks. Does this need to be uncommented, what difference does it make? It is still commented in mine and everything is working.

There’s also this line: #Options -Indexes ?


BB6 Band My band
Gud One My blog

Offline

Board footer

Powered by FluxBB