Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-08-30 21:12:53

philwareham
Core designer
From: Farnham, Surrey, UK
Registered: 2009-06-11
Posts: 3,188
Website

Host textpattern images on a subdomain for speed increase

Hi,

I’ve been playing around with Google’s page speed plugin for Firebug on a new site I’m building and following their recommendations to see how high I can get the page speed rating – currently I’ve got to 93/100 but have hit a wall…

One of the Google recommendations is to serve images (and other static content such as css, javascript) from a subdomain to take advantage of parallel downloads and also the fact that you can make the subdomain cookieless.

This is no problem for any images outside of textpattern management, but I can’t seem to find a way to specify a subdomain for the textpattern images folder, as the admin->advanced preferences states that it has to be a relative URL to the textpattern folder. Can this be done at all? I’ve noticed that you can set an absolute server path for files but not it seems for images.

I found this old forum post which brushed on this topic before, but noone thought it a worthwhile pursuit back in 2006. I don’t want to use 301 redirects or anything hacky in the htaccess file either.

I realise this is quite OCD but it would be nice if there was a solution!

Offline

#2 2010-08-30 22:06:32

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: Host textpattern images on a subdomain for speed increase

philwareham wrote:

I realise this is quite OCD but it would be nice if there was a solution!

I’m pretty sure you’re not alone in having that condition round these parts. I’ve been trying to figure the same thing for a while now. Haven’t tried hard, I admit. I figured it might just come to me in a flash.

So far, no flashes.

It would make sense to serve txp files from a static domain too. The bonus would be making version control a whole lot simpler with all those content files out of the way. When he returns from training up in the mountains I’m hoping Maniqui will have the answer to this and other hithero unsolvable mysteries of the universe.

ps. Your site feels pretty zippy already – looks like the page speed homework paid off :-)

Offline

#3 2010-08-30 23:32:51

JimJoe
Member
From: United States
Registered: 2010-01-30
Posts: 490
Website

Re: Host textpattern images on a subdomain for speed increase

Note that some web hosts may not allow it, their ‘anti-hot linking’ filters may see it as an attempt to steal bandwidth, even though it is your pictures it is linking to in a sub-domani. You might ask them about it.

As for how, I don’t think it is all that hard.

If your domain is www.joe.net and you make a sub-domain of bill.joe.net with an images folder in bill.joe.net

<,img src=“http://bill.joe.net/images/name_of_file”></a> on a page in www.joe.net

I put the comma in there to show the html markup. I’m still learning the methods used here.

Offline

#4 2010-08-31 05:45:20

wet
Developer
From: Lenzing, Austria
Registered: 2005-06-06
Posts: 3,267
Website

Re: Host textpattern images on a subdomain for speed increase

The upcoming Textpattern 4.3.0 release will support a new configuration constant ihu in config.php for this purpose. Example:

define('ihu', 'http://static.example.com/');

See r3350 for details.

Offline

#5 2010-08-31 08:02:35

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: Host textpattern images on a subdomain for speed increase

Great news. Thanks Wet.

Offline

#6 2010-08-31 09:39:09

philwareham
Core designer
From: Farnham, Surrey, UK
Registered: 2009-06-11
Posts: 3,188
Website

Re: Host textpattern images on a subdomain for speed increase

Thanks all, I’m using r3380 from SVN anyway so I’ll check out that config and let you know how I get on.

@JimJoe, the original issue was that textpattern (up to 4.2.0 anyway) needs it’s images folder in the same domain as the textpattern install, thanks anyway.

pieman wrote:

ps. Your site feels pretty zippy already – looks like the page speed homework paid off :-)

Thanks, that site (lovethegarden.com) is not the one I’ve been optimising (although I have done some speed work on it previously) but I will move all techniques from my new site back to that one as well eventually. There really is a noticeable speed improvement when following Google’s speed tips which I’m quite surprised/pleased about.

For the record, I don’t think is possible to achieve 100/100 on Google Speed Tools (the Google UK homepage only scores 93 itself).

Offline

#7 2010-08-31 09:46:52

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: Host textpattern images on a subdomain for speed increase

A little promotion for a commercial tool which I use as my swiss army knife to speed up sites. ‘Distribute images’ is one of the many features.


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#8 2010-08-31 12:32:04

philwareham
Core designer
From: Farnham, Surrey, UK
Registered: 2009-06-11
Posts: 3,188
Website

Re: Host textpattern images on a subdomain for speed increase

Using textpattern r3380, my previous place for storing images was www.mysite.com/images/cms/ and I now want my site to serve txp images from static1.mysite.com/images/cms/ so:

1. Added following code to config.php

define('ihu', 'http://static1.mysite.com/')

2. Left the images directory in admin->advanced preferences as “/images/cms”

3. Moved existing images to the subdomain and made the folder chmod 777

Now all existing images are now served from the subdomain as expected which is great, but if I add a new image through textpattern it is not being loaded into the directory in the subdomain. In fact, it’s still wrting new images to the old directory at www.mysite.com/images/cms/

Is this a bug or have I set it up wrong?

Offline

#9 2010-08-31 13:00:43

wet
Developer
From: Lenzing, Austria
Registered: 2005-06-06
Posts: 3,267
Website

Re: Host textpattern images on a subdomain for speed increase

From your webserver’s file system point of view, the images have to stay in their original directory. Textpattern will always add new images just like it does without the optional ihu constant in config.php. Do not move or copy the image files.

The most simple setup is to define static.example.com as a mirror domain for www.example.com. Thus, images are served from http://static.example.com/images/cms/ and saved into the webserver’s file system at $WEBROOT/images/cms/.

Offline

#10 2010-08-31 13:29:32

philwareham
Core designer
From: Farnham, Surrey, UK
Registered: 2009-06-11
Posts: 3,188
Website

Re: Host textpattern images on a subdomain for speed increase

Oh, I see. Would it not be a better option to allow an absolute path for images in the admin preferences like it is for files? Sorry, but I have no knowledge of how much work that would be to engineer or even if it’s possible – but from an end user perspective that would be the best option.

Offline

Board footer

Powered by FluxBB