MULTIPLE cookieless domains (speed improvement)
by
10 Jul 2010
Since vbulletin uses a LOT of images plus CSS and JS i decided to separate all of them into cookie less domains First of all on admincp set cookies only for your forum MAIN domain (ie www.mysite.com) not .mysite.com DNS: First of all i created some subdomains static.mysite.com static2.mysite.com staticcss.mysite.com staticjs.mysite.com all of them pointing to the same server Web server: i created a new vhost: Code:
<VirtualHost *:80> ServerAdmin email" DocumentRoot "/usr/local/www/estaticos_mysite_com" ServerName static.mysite.com ServerAlias static2.mysite.com staticcss.mysite.com staticjs.mysite.com ErrorLog "/var/log/www/mysite-error.log" CustomLog "/var/log/www/mysite-access.log" combined Alias /images /usr/local/www/web_mysite_com/images Alias /clientscript /usr/local/www/web_mysite_com/clientscript </VirtualHost> My vb site is in: /usr/local/www/web_mysite_com and the static content is in: /usr/local/www/estaticos_mysite_com inside this new vhost directory i also made two aliases (because of my permissions) clientscript -> ../web_mysite_com/clientscript images -> ../web_mysite_com/images * given my permission direct access to this shite would give you a forbidden, maybe you could create an empty index file htaccess: i have a redirect for my domain so now i had to make a few changes to: Code:
RewriteCond %{HTTP_HOST} !^www\.mysite\.com RewriteCond %{HTTP_HOST} !^static\.mysite\.com RewriteCond %{HTTP_HOST} !^static2\.mysite\.com RewriteCond %{HTTP_HOST} !^staticcss\.mysite\.com RewriteCond %{HTTP_HOST} !^staticjs\.mysite\.com RewriteRule (.*) http://www.mysite.com/$1 [L,R=301] go to your admincp and create a new plugin in global_complete hook Code:
$oz_process = str_replace('"http://www.mysite.com/clientscript/vbulletin_css/', '"http://staticcss.mysite.com/clientscript/vbulletin_css/', $output); $oz_process = str_replace('"clientscript/vbulletin_css/', '"http://staticcss.mysite.com/clientscript/vbulletin_css/', $oz_process); $oz_process = str_replace('"http://www.mysite.com/clientscript/', '"http://staticjs.mysite.com/clientscript/', $oz_process); $oz_process = str_replace('"clientscript/', '"http://staticjs.mysite.com/clientscript/', $oz_process); $output = $oz_process; Spoiler (click to open)
So I was playing around with YSlow today and made some progress on improvements. Having some issues getting .js and some .css to compress with gzip but this is in Windoze.
I made a quick plug-in and hooked it as the last thing on global_start to swap out some of my images and other content to my subdomain CDN's. Not sure if my approach is correct but it seems to making YSlow happier anyway: Code:
$oz_process = str_replace('"http://ozscience.com/forums/clientscript/', '"http://cdn8.ozscience.net/clientscript/', $output); $oz_process = str_replace('"clientscript/', '"http://cdn8.ozscience.net/clientscript/', $oz_process); // $oz_process = str_replace('"http://ozscience.com/common/', '"http://cdn8.ozscience.net/common/', $oz_process); $oz_process = str_replace('"http://ozscience.com/forums/images/', '"http://cdn9.ozscience.net/images/', $oz_process); $output = str_replace('"/forums/images/', '"http://cdn9.ozscience.net/images/', $oz_process); Close
images: Go yo "templates and styles" choose your style and then in Style Vars filter by imgdir replace those PATHs with new-hostname/ + original path IE: images/buttons -> http://static2.mysite.com/images/buttons NOTE: because a bug in vb code here you can make a real mess, check this report first: http://tracker.vbulletin.com/browse/VBIV-7479 * Long story short: a solution that worked for me was from David Grove:
|
Similar Mods
[Improvement] vBStats -> Top Posters list PHP-code improvement (much less queries) | vBulletin 2.x Full Releases |
[Improvement] vBStats -> Member Referrer list PHP-code improvement (much less queries | vBulletin 2.x Full Releases |