produke
3-23-07, 09:29 PM
Learned a cool way (http://www.askapache.com/2007/webmaster/faster-google-analytics-with-a-local-urchinjs.html) to speed up site loading time by serving an updated urchin.js file locally.
Normally the Google Analytics urchin.js file is located on the google-analytics.com server, which is clear from the Analytics Tracking Code you install on your site.
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
Official Google Position on locally hosting urchin.js (http://www.google.com/support/analytics/bin/answer.py?answer=43183&query=urchin.js&topic=&type=)
Can I host the urchin.js file locally?
While you are welcome to download the file to examine, we do not recommend that users serve the urchin.js themselves.
Most people wish to host urchin.js locally in order to avoid making their users download it from Google every time they request a page. However, urchin.js is designed to be downloaded once from Google and is then served from the visitor's cache.
Referencing the urchin.js file from Google's servers will ensure that you are using the most current version, allowing you to easily obtain new features and other enhancements as they become available. This will help make your reports as accurate as possible.
The problem is when google-analytics.com/urchin.js is requested by billions of web users all over the world at one time, it can cause your sites pages to load at a snails pace. Especially if you are using WordPress or a similar CMS.
HTTP Headers sent with urchin.js from the google-analytics server.
Cache-Control: max-age=604800, public
Content-Type: text/javascript
Last-Modified: Tue, 20 Mar 2007 22:51:38 GMT
Content-Encoding: gzip
Server: ucfe
Content-Length: 5675
Date: Fri, 23 Mar 2007 21:59:07 GMT
Notice the Cache-Control (http://www.askapache.com/2006/htaccess/speed-up-sites-with-htaccess-caching.html) header specifies that the urchin.js file should be cached for 1 week (604800 seconds) which directs your browsers cache to check the remote urchin.js file every week to see if it has been modified.
Get your local urchin.js
This method downloads an updated urchin.js file every 24 hours and saves it into your local sites directory.
So instead of this
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-333153-x";urchinTracker();
</script>
its this
<script src="/z/j/urchin.js" type="text/javascript"></script>
<script type="text/javascript">
_uacct = "UA-333153-x";urchinTracker();
</script>
This automated process is controlled by crontab and executes a simple shell script that retrieves the updated urchin.js file and saves it into your local server. shell script and crontab code (http://www.askapache.com/2007/webmaster/faster-google-analytics-with-a-local-urchinjs.html)
So what do you think? cool huh!
Normally the Google Analytics urchin.js file is located on the google-analytics.com server, which is clear from the Analytics Tracking Code you install on your site.
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
Official Google Position on locally hosting urchin.js (http://www.google.com/support/analytics/bin/answer.py?answer=43183&query=urchin.js&topic=&type=)
Can I host the urchin.js file locally?
While you are welcome to download the file to examine, we do not recommend that users serve the urchin.js themselves.
Most people wish to host urchin.js locally in order to avoid making their users download it from Google every time they request a page. However, urchin.js is designed to be downloaded once from Google and is then served from the visitor's cache.
Referencing the urchin.js file from Google's servers will ensure that you are using the most current version, allowing you to easily obtain new features and other enhancements as they become available. This will help make your reports as accurate as possible.
The problem is when google-analytics.com/urchin.js is requested by billions of web users all over the world at one time, it can cause your sites pages to load at a snails pace. Especially if you are using WordPress or a similar CMS.
HTTP Headers sent with urchin.js from the google-analytics server.
Cache-Control: max-age=604800, public
Content-Type: text/javascript
Last-Modified: Tue, 20 Mar 2007 22:51:38 GMT
Content-Encoding: gzip
Server: ucfe
Content-Length: 5675
Date: Fri, 23 Mar 2007 21:59:07 GMT
Notice the Cache-Control (http://www.askapache.com/2006/htaccess/speed-up-sites-with-htaccess-caching.html) header specifies that the urchin.js file should be cached for 1 week (604800 seconds) which directs your browsers cache to check the remote urchin.js file every week to see if it has been modified.
Get your local urchin.js
This method downloads an updated urchin.js file every 24 hours and saves it into your local sites directory.
So instead of this
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-333153-x";urchinTracker();
</script>
its this
<script src="/z/j/urchin.js" type="text/javascript"></script>
<script type="text/javascript">
_uacct = "UA-333153-x";urchinTracker();
</script>
This automated process is controlled by crontab and executes a simple shell script that retrieves the updated urchin.js file and saves it into your local server. shell script and crontab code (http://www.askapache.com/2007/webmaster/faster-google-analytics-with-a-local-urchinjs.html)
So what do you think? cool huh!