WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Webmaster Resources Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Webmaster Resources Discussion Forum Sitemaps and robots and logfiles -- Oh My! If you have any questions, comments, concerns and/or ideas about the tools currently available to webmasters to make their lives... 'easier'. Here's where you need to be. Know of a good tool? Post it here. Got something funny in your logfiles? Maybe we can help.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-24-2007, 04:05 PM
WebProWorld Member
 

Join Date: Dec 2006
Location: Indianapolis
Posts: 41
modrewrite RepRank 0
Default Benefits of hosting Googles urchin.js locally

Original Article

There are 2 pretty major things that you accomplish by hosting urchin.js locally
  1. You Enable persistant connections
  2. You ensure that the correct 304 Not Modified header is sent back to your site visitors instead of reserving the entire file.

This method uses crontab to execute a shell script that downloads an updated urchin.js file every 24 hours and saves it into your local sites directory.

Official Google Position on locally hosting urchin.js


Setup crontab by typing crontab -e at a unix-style command prompt (ssh) then add:
Code:
11 12 * * * /home/user/websites/urch.sh >/dev/null 2>&1
shell script example
Code:
#!/bin/sh
rm /home/user/websites/askapache.com/z/j/urchin.js
cd /home/user/websites/askapache.com/z/j/
wget http://www.google-analytics.com/urchin.js
chmod 644 /home/user/websites/askapache.com/z/j/urchin.js
cd ${OLDPWD}
exit 0;

One problem with the google-analytics.com/urchin.js file is that the server does not allow persistant connections.

Another big issue is that instead of responding to an If-Modified-Since header correctly with a 304 Not Modified header - indicating the file has not been modified, google-analytics.com returns the entire urchin.js file all over again, thus rendering the cache-control in place voided.

You can see this problem clearly with a wireshark capture.

Code:
GET /urchin.js HTTP/1.1
Accept: */*
Referer: http://www.askapache.com
Accept-Language: en-us
UA-CPU: x86
Accept-Encoding: gzip, deflate
If-Modified-Since: Tue, 20 Mar 2007 22:49:11 GMT
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SU 2.011; .NET CLR 1.1.4322; .NET CLR 2.0.50727; Alexa Toolbar; .NET CLR 3.0.04506.30)
Host: www.google-analytics.com
Connection: Keep-Alive
Code:
HTTP/1.1 200 OK
Cache-Control: max-age=604800, public
Content-Type: text/javascript
Last-Modified: Tue, 20 Mar 2007 22:54:02 GMT
Content-Encoding: gzip
Server: ucfe
Content-Length: 5675
Date: Sat, 24 Mar 2007 18:23:12 GMT
Note: You will need a caching scheme on your server for optimum results.

Overkill!
__________________
de // AskApache.com blog
Reply With Quote
  #2 (permalink)  
Old 03-31-2007, 07:52 AM
WebProWorld Member
 

Join Date: Dec 2006
Location: Indianapolis
Posts: 41
modrewrite RepRank 0
Default

Yup.. its faster
__________________
de // AskApache.com blog
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Webmaster Resources Discussion Forum
Tags: , , , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0