Archive | Web Development RSS feed for this section

15 October 2009 View Comments

Move your .htaccess directives to httpd.conf

htaccess

htaccessLast week I was searching the net for a program or application to  move some of our .htaccess directives into Apache’s configuration files. The reason I was looking for this is to improve the performance of the site. When we have directives in the .htaccess file, the performance hit on Apache on when it serves each URL is accessed.

If you have a .htaccess file in your web folders, Apache will have to parse the directives in this file and see if there are any .htaccess files in the parent folder. All this happens before your html or php file is hit by Apache. You can read more about the overheads of .htaccess in  this article. This article .htaccess vs httpd.conf by Dawid Golunski shows that he saw apache served about 6.6% less requests/second when .htaccess was used.

A quick Google search landed me on Paul Reinheimer’s blog where he’s created a php script just for this purpose. His htaccess to httpd.conf script parses all the htaccess files from the current folder and all sub-folders and creates a configuration file with the directives for you to place in your Apache’s configuration file.

Just download his script from this link, and place it in your web-root directory which you want to generate the Apache configuration file and run the following command from the command prompt:

php htaccess.php >~/site.conf

After you run that command, you should have a file site.conf in your home folder. You can open this file to get all the directives for you to place in the Apache configuration file. Once you’ve placed this in the apache configuration file, you’ll need to restart Apache for the changes to take effect. Before you restart, make sure you remove your .htaccess file from your web folders.

When I converted a WordPress’ .htaccess file using this script, here’s the output I got

<directory var="" www="" blog="">
	<ifmodule mod_rewrite.c="">
	RewriteEngine On
	RewriteBase /
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule . /index.php [L]
	</ifmodule>
</directory>

I just put this into the apache2.conf and restarted it, removed the .htaccess from the webroot in /var/www/blog and all the rules worked as they should. As with any script, if you have more complex directives in your .htaccess, test your sites thoroughly before pushing your changes into the production server.

The only (minor) disadvantage I found with this method is that the apache server has to be restarted to make changes to your rule-sets you put in the configuration files. It seems apache just has to be reloaded and doesn’t have to be completely restarted to get the changes to the configuration to take effect (thanks Keleo for the tip). Also this conversion will not be possible if your site is running on a shared webhost where you don’t have access to the apache configuration files.

Links:
Paul Reinheimer’s Article .htaccess to httpd.conf
Paul’s htaccess.php Script
htaccess vs httpdconf – Benchmarks

Reblog this post [with Zemanta]

14 July 2009 View Comments

PHP 5.3 & Internationalization

Unicode_sample

Unicode_sampleStas Malyshev has written a good article over at Zend Developer Zone about the new intl – Internalization extension in PHP 5.3. Internationalization has been a major problem with web developers when developing sites which have to support multiple languages. The new extension eases the developer’s work drastically. Stas mentions in the article that the following modules have been implemented in the Intl extension:

  • Locale — deals with breaking locale data into components, assembling a locale string from components and displaying the names of countries, languages etc in a specified locale.
  • Collator — a means of comparing and sorting strings according to local rules.
  • Number formatter — allows you to format numbers in a variety of ways, and to parse textual representations of numbers.
  • Date formatter — allows you to format dates and to parse textual representations of dates.
  • Message formatter — allows you to compose messages from parameterized strings while formatting the data inside according to local rules and allowing choices dependent on the actual parameter value.
  • Normalizer — a means of bringing a Unicode string to a standard, unambiguous representation.
  • Grapheme module – handles parsing a string into a set of graphemes.
  • IDN – handles internationalized domain names format

Read Stas’ article to learn how to use the new features this extension provides to make your website Internationalization ready.

If you’re using PHP5.2, you’re in luck since there is a PECL package which should run on PHP 5.2.4 and newer over at: http://pecl.php.net/package/intl

Link: http://devzone.zend.com/article/4799-Internationalization-in-PHP-5.3

Image via Wikipedia

Reblog this post [with Zemanta]

Tags: ,
5 June 2009 View Comments

Google Page Speed

page-speed-javascript-defered1

page-speedWeb developers have to check out Google’s new Firefox + Firebug addon called Page Speed. This addon inspects your webpage to see how you can optimize the load time. Yahoo’s YSlow was good, but Google takes it a few steps further to even inspect your html and styles to see what can hider the render time of the page once it’s loaded.

Apart from the standard tests on if your content is gzipped, server headers are correct and enable client side caching and parallelizing downloads from differnent host names, this addon also does the following:

  • Inspect your CSS files for unused styles
  • Inspect your Cookie size – the bigger the cookie size, the bigger the request sent to the server everytime, since every request will send your cookies from the browser to the server
  • Checks image compression ratios to see if you’re running on the optimal compression.
  • Checks to see if your Javascript is minified, if not, it’ll show you how much you can save if you minify your javascripts
  • Inspects the execution of Javascript on the page on load to show which Javascript files can be deferred in loading, by placing the Javascript loads at the end of the page instead of the head. This can drastically increase the page render times.
  • If you load multiple Javascripts and CSS files, Page speed will give you recommendations to merge these into a single file.

Page Speed helps you improve your site’s performance based on the following categories of best practises:

Get Google Page Speed at: http://code.google.com/speed/page-speed/

Screenshots:

Google Page Speed Recommendations

Google Page Speed Recommendations

CSS Optimization Recommendations

CSS Optimization Recommendations

Javascript Minify Savings

Javascript Minify Savings

Suggestion to Defer Javascript Loading

Suggestion to Defer Javascript Loading

11 July 2008 View Comments

MVC Frameworks and 404s

404

Mark Kimsal has an interesting article on whether your MVC frameworks handle 404 errors properly.

“This post is about the consistency of frameworks. Consistency is key to a low learning curve. If all parts of a framework behave the same way, then a developer is less likely to be surprised by behaviors in the framework. Also, I feel that they are less likely to rely on a manual every couple of minutes to look up method names, directory names, etc.

Given the fact that most, if not all, MVC frameworks use a front-controller pattern, there is never a missing file error (404) at the Apache level. Apache is always finding the index.php file that kicks off the MVC application.”

Be sure to add your thoughts and read the comments at the end of his post. Head over to the post Is Your MVC MIA When it Comes to 404s?

Zemanta Pixie

Tags:
28 May 2008 View Comments

Google: Ajax Libraries API

Google: Ajax Libraries API

Here’s some cool stuff – Google’s Hosting some popular Javascript Ajax libraries like jQuery, prototype and the likes on their servers. You use this service to serve the supported libraries straight off Google. They also provide you with the option to load a particular version of the library so you won’t have to keep checking your code everytime a latest release is made.

Here’s how you would load jQuery version 1.2.3 using this API:

<script src="http://www.google.com/jsapi"></script>
<script>
  // Load jQuery 
  google.load("jquery", "1.2.3");
 //Continue using jQuery
</script>

The AJAX Libraries API is a content distribution network and loading architecture for the most popular open source JavaScript libraries. By using the Google AJAX API Loader’s google.load() method, your application has high speed, globaly available access to a growing list of the most popular JavaScript open source libraries including:

Google works directly with the key stake holders for each library effort and accept the latest stable versions as they are released. Once we host a release of a given library, we are committed to hosting that release indefinitely.

Links:

Google Ajax Libraries

Documentation

Zemanta Pixie

16 May 2008 View Comments

Google Doctype

Google Doctype
A graphical depiction of a very simple css document

Google Doctype is an open encyclopedia and reference library. Written by web developers, for web developers. It includes articles on web security, JavaScript DOM manipulation, CSS tips and tricks, and more. The reference section includes a growing library of test cases for checking cross-browser and cross-platform compatibility.

This site’s currently got some good HOWTOs on Web security, DOM manipulation, CSS and styles and more. A worthwhile place to check if you’re looking at some quick reference and help.

Link: Google Doctype

13 May 2008 View Comments

Google Friend Connect

google-friend-connect

Google’s just released a preview version of Google Friend Connect, which allows you to add social features on your site with minimal coding. This is still a preview release so you’ll have sign up to get into the queue.

Google Friend Connect lets you grow traffic by easily adding social features to your website. With just a few snippets of code, you get more people engaging more deeply with your site.

Here’s a video introduction of Google Friend Connect:

Link: Google Friend Connect

8 April 2008 View Comments

Google App Engine Launched

Google App Engine Launched

Google App Engine

Just out a few hours back – The Google App Engine – it’s a preview release, and I was late in getting to this news and missed out on the initial invites – but have added myself to the invite queue.

PHP devs may curse Google on this since Python is only supported language out here in Google App Engine territory.

Google App Engine gives you access to the same building blocks that Google uses for its own applications, making it easier to build an application that runs reliably, even under heavy load and with large amounts of data. The development environment includes the following features:

  • Dynamic webserving, with full support of common web technologies
  • Persistent storage (powered by Bigtable and GFS with queries, sorting, and transactions)
  • Automatic scaling and load balancing
  • Google APIs for authenticating users and sending email
  • Fully featured local development environment

Google App Engine packages these building blocks and takes care of the infrastructure stack, leaving you more time to focus on writing code and improving your application.

Link: http://appengine.google.com/

via: Introducing Google App Engine + our new blog

Zemanta Pixie

Tags:
7 April 2008 View Comments

DamnIT – Find Javascript Errors

DamnIT Notification

DamnIT Notification

How would you like to get an email with the javascript error and debug info about that error as soon as a visitor on your site encounters it? DamnIT provides you just that service:

DamnIT is a free service that emails you when a user encounters a JavaScript error in your webpages.

To get DamnIT installed for your site, just signup for an account and call a JS script – this works fine for IE and Firefox. If you want to install DamnIT on other browsers, you’ll need to place try…catch blocks. Learn more about DamnIT over at: http://damnit.jupiterit.com/home/learn

Link : DamnIT: Javascript Error Handling

Tags:
14 February 2008 View Comments

10 Principles Of Effective Web Design

Usability and the utility, not visual design, determine success or failure of a web-site. Since visitor page is only person who clicks mouse therefore decides everything, user-centric design has become standard approach for successful profit-oriented

Link: 10 Principles Of Effective Web Design | How-To | Smashing Magazine

Sent from BlueOrganizer

Tags: ,