Friday, January 11, 2008

Use a custom php.ini with mod_php or php as a cgi

Describes in exhaustive detail how to change configuration settings and implement a custom php.ini file for use with the Apache Web Server.

PHP run as Apache Module (mod_php)

Add this to your root .htaccess file. Say your php.ini is in folder /askapache.com/ini/

SetEnv PHPRC /askapache.com/ini

Caching Techniques for Apache .htaccess Gurus

This article shows 2 awesome ways to implement caching on your website using Apache .htaccess (httpd.conf) files on the Apache Web Server. Both methods are extremely simple to set up and will dramatically speed up your site!

Apache .htaccess caching code

# 1 YEAR

Header set Cache-Control "max-age=29030400, public"

# 1 WEEK

Header set Cache-Control "max-age=604800, public"

# 2 DAYS

Header set Cache-Control "max-age=172800, proxy-revalidate"

# 1 MIN

Header set Cache-Control "max-age=60, private, proxy-revalidate"

For fail-safe code implement this to the above


# any Expires Directives go here



# any Header directives go here

At least one of the 2 modules needs to be built into Apache; although they are included in the distribution, they are not turned on by default. To find out if the modules are enabled in your server, find the httpd binary and run httpd -l; this should print a list of the available modules. The modules we're looking for are mod_expires and mod_headers.

If they aren't available, and you have administrative access, you can recompile Apache to include them. This can be done either by uncommenting the appropriate lines in the Configuration file, or using the -enable-module=expires and -enable-module=headers arguments to configure (1.3 or greater).

Complete Article

Thursday, December 06, 2007

Becoming PHP 6 Compatible

In a new post on 'Making the Web blog', there's a new post that talks about preparing your code for PHP6 when it comes around. "If you want to make use of PHP 6 when it comes, you're going to have to write your new scripts so they are compatible, and possibly change some of your existing scripts. To start making your scripts PHP 6 compatible, I've compiled a list of tips to follow when scripting." The list of tips has five entries:

  • Don't use register_globals
  • Stop using magic_quotes
  • Don't Register Long Arrays
  • preg instead or ereg
  • Don't initiate objects with the reference operator

Saturday, November 10, 2007

How to turn a php script to an exe..for free

There is an interesting article in jaslab go through this article Click here.

Saturday, June 30, 2007

Measuring the effective bandwidth of your users

Its Sample javascript implementing this.. Just go through this article

http://www.die.net/musings/page_load_time/

Wednesday, May 16, 2007

How to find slow mysql queries?

By Justin Silverton

It has happened to all of us running a website or application using mysql as its back-end database. Performance is suddenly very sluggish and you have no idea what is causing it. Now there may be other factors that are causing the issue (overloaded CPU, harddrive running out of space, or a lack of bandwidth), but it could also be a query that is not optimized and/or is taking much longer than it should to return.

How do you know which queries are taking the longest to execute? Mysql has built-in functionality for checking this through the slow query log.

To enable (do one of the following):

1) add this to /etc/my.cnf

log-slow-queries=/tmp/slow_queries.log
long_query_time=10

2) call mysqld with –log-slow-queries[=/tmp/slow_queries.log]

long_query_time is the maximum amount of seconds a query can take before it will be logged to the slow query log.

other related options:

–log-slow-admin-statements

Log slow administrative statements such as OPTIMIZE TABLE, ANALYZE TABLE, and ALTER TABLE to the slow query log.

–log-queries-not-using-indexes

If you are using this option with –log-slow-queries, queries that do not use indexes are logged to the slow query log.

If slow query logging has been enabled successfully, you will see “ON” in the VALUE field for “log_slow_queries” (shown above).

Note: Queries handled by the query cache are not added to the slow query log, nor are queries that would not benefit from the presence of an index because the table has zero rows or one row.

You may also run into the case where a query is slow at one time (such as when you are logging it) but not another (if you execute it manually):

* A table may be locked, causing the query to wait. the lock_time indicates how long the query waited for locks to be released
* none of the data or indexes have been cached in memory. This is common when MySQL first starts or your tables have not been optimizied
* a background process was running, making disk I/O considerably slower
* The server may have been overloaded with other unrelated queries at the same time, and there wasn’t enough CPU power to do the job efficiently

Log analysis

MySQL also comes with mysqldumpslow, a perl script that can summarize the slow query log and provide a better idea of how often each slow query executes.

Thursday, March 29, 2007

sorttable: Make all your tables sortable

Do you want to sort the tabular data?

Follow the Link.

Tuesday, March 27, 2007

How to add keyboard shortcuts to your website

By Justin Silverton

The following javascript code will allow you to add keyboard shortcuts to any webpage.

The code

(put this on any page where you want keyboard shortcuts)

I can't put the HTML code please refer:- Html Code

(put this in a file called shortcut.js and upload to the same directory as the webpage with the above code). This example will display an alert message when the escape key is pressed.

function keyShortcut() {
var e = window.event;
var code = e.keyCode;
if (code == 112) { //checks for the escape key
alert('escape key pressed');
}
}

The following are some more keyboard codes that can be used within the above script (in the if code == X, where X is one of the codes below).

key Code
tab 9
enter 13
leftwindow key 91
right window key 92
f1 112
f2 113
f3 114
f4 115
f5 116
f6 117
f7 118
f8 119
f9 120
f10 121
f11 122
f12 123