InProgress... The Newsletter
September 07, 2010, 04:12:13 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: I'm replacing my old blogger accounts with this.
 
   Home   Help Search Calendar Tip Mug Members Login Register  
Pages: [1]
  Print  
Author Topic: Site Speed Upgrades!  (Read 333 times)
0 Members and 1 Guest are viewing this topic.
mr_coffee
Administrator
*****

Caffeine: +65535/-0
Offline Offline

Posts: 53


there is no such thing as impossible


WWW
« on: March 28, 2008, 12:55:35 PM »

Subdomains
Browsers are limited to how many requests they can make to each URL.  Fortunately, they count subdomains as separate requests.  For a little quicker access, I highly recommend making a subdomain for "images", "js" and "css" and ensure that all code related to your images, scripts and style sheets are absolute links to the files in those subdomains.  It helps!

GZip your files!
Why?  Because you can.  Saves bandwidth and minimizes server load.  MAKES PEOPLE HAPPY!  And we all want that, right?  In any case, this method is ideal: gzip your css and js files and whatever else you like... UPLOAD BOTH - because some browsers are stupid... and then modify your .htaccess file to include the following:

Code:
RewriteEngine on
RewriteOptions Inherit

#Check to see if browser can accept gzip files.
ReWriteCond %{HTTP:accept-encoding} (gzip.*)

#make sure there's no trailing .gz on the url
ReWriteCond %{REQUEST_FILENAME} !^.+\.gz$

#check to see if a .gz version of the file exists.
RewriteCond %{REQUEST_FILENAME}.gz -f

#All conditions met so add .gz to URL filename (invisibly)
RewriteRule ^(.+) $1.gz [L]

This is a really neat .htaccess trick.  Checks to see if there is a .gz copy of the file... if so, that's the one the visitor gets.  Note that when updating a site... you won't see your change until you send your gzip copy to the server since your browser is NOT retarded.  This gets... slightly confusing at times.  I recommend taking down the gzip copies of the files you're changing until you're done.  I believe this will work with a file of ANY extension but I've limited my use to scripts and stylesheets so far.

The author of this kick-butt .htaccess file is NOT me but Patrick Hunlock: http://www.hunlock.com/blogs/Compressed_HTML_makes_your_pages_zippy.  By far the best method I've seen as it works without the use of confusing PHP code that may or may not work on all servers.

On a side note... this method just STOPPED working for me yesterday when my web host upgraded their copy of Apache.  As a few other parsing issues came up at the same time, there appears to be a bug with the newest Apache they're still trying to hammer out.  In any case, that issue will be resolved, and it's still the best method I've seen.
« Last Edit: April 03, 2008, 11:08:07 PM by mr_coffee » Logged
mr_coffee
Administrator
*****

Caffeine: +65535/-0
Offline Offline

Posts: 53


there is no such thing as impossible


WWW
« Reply #1 on: April 03, 2008, 05:05:07 PM »

Welp... when Apache 2.2 rolled out... the aforementioned .htaccess file was rendered useless.  I saw someone else get theirs to work, but don't know how they pulled it off.  If you have a VERY COOL WEBHOST... like mine... you can add the following line:

Code:
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript

Now... no need to pre-zip your own files, the server will now be sending them all that way... including html files being generated by php... pretty cool, eh?  It's been argued that this adds a little to server load... but it sounds as though the decreased bandwidth simultaneously drops server load... SO... you either even out or come out ahead, I'm not sure which.  Depends on the files.  mod_deflate ignores files under 1K from what I hear, so the server won't bother trying to compress those.

Just in case, I'm still working on a way to get the past .htaccess file to work right in case a server won't enable mod_deflate for you (previously mod_gzip), but I'm coming up empty.  The only post I saw about this issue... they did what I'd already done that had ceased to function with the new Apache.  It might work for you, who knows? 

Anyway, your browser is now decrompessing my entire site now, not just the .js and .css.  Thank your browser for me.  You might note a significant improvement in speed if you've been visiting a lot I guess.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!