<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Technology Forum</title>
	<atom:link href="http://technology.freenetsolutions.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://technology.freenetsolutions.com</link>
	<description>SEO, Speed Up website, Server Optimization, Linux, Open Source Softwares</description>
	<pubDate>Tue, 20 May 2008 03:57:58 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>HTTP header and Server Response Codes</title>
		<link>http://technology.freenetsolutions.com/2008/05/http-header-and-server-response-codes/</link>
		<comments>http://technology.freenetsolutions.com/2008/05/http-header-and-server-response-codes/#comments</comments>
		<pubDate>Mon, 19 May 2008 14:27:13 +0000</pubDate>
		<dc:creator>infoweb</dc:creator>
		
		<category><![CDATA[Web Server]]></category>

		<category><![CDATA[Codes]]></category>

		<category><![CDATA[Errors]]></category>

		<category><![CDATA[Header Check]]></category>

		<category><![CDATA[HTTP]]></category>

		<category><![CDATA[Server Header]]></category>

		<category><![CDATA[Server Response]]></category>

		<guid isPermaLink="false">http://technology.freenetsolutions.com/?p=5</guid>
		<description><![CDATA[Introduction
HTTP is a transfer protocol used by the World Wide Web (WWW) to retrieve information from distributed servers. The HTTP model is extremely simple; the client establishes a connection to the remote server, then issues a request. The server then processes the request, returns a response, and closes the connection. Most HTTP communication is initiated [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>HTTP is a transfer protocol used by the World Wide Web (WWW) to retrieve information from distributed servers. The HTTP model is extremely simple; the client establishes a connection to the remote server, then issues a request. The server then processes the request, returns a response, and closes the connection. Most HTTP communication is initiated by a user agent and consists of a request to be applied to a resource on some origin server. HTTP communication usually takes place over TCP/IP connections. The default port is TCP 80, but other ports can be used like 21 (FTP), 443 (HTTPS).<span id="more-5"></span></p>
<p><strong>Requests</strong>:  The request format for HTTP is quite simple. The first line specifies an object, together with the name of an object to apply the method to. The most commonly used method is &#8220;GET&#8221;, which ask the server to send a copy of the object to the client. The client can also send a series of optional headers. The most common headers are &#8220;Accept&#8221;, which tells the server which object types the client can handle, and &#8220;User-Agent&#8221;, which gives the implementation name of the client.</p>
<p><strong>Responses</strong>: The response format is also quite simple. Responses start with a status line indicating which version of HTTP the server is running, together with a result code and an optional message. This is followed by a series of optional object headers; the most important of these are &#8220;Content-Type&#8221;, which describes the type of the object being returned, and &#8220;Content-Length&#8221;, which indicates the length.The headers are teminated by an empty line.  The server now sends any requested data. After the data have been sent, the server drops the connection.</p>
<p><strong>Headers</strong>: Headers are short fragments of text which are generated by servers to hold information pertaining to each transfer as it occurs. There are four kinds of headers:</p>
<ol type="a">
<li><em>General-Header</em>: These are few header fields which have general applicability for both request and response messages.  These header fields apply only to the message being transmitted which include Cache-Control, Connection, Date, Pragma, Transfer-Encoding etc.</li>
<li><em>Request-Header</em>: The request-header fields allow the client to pass additional information about the request, and about the client itself, to the server.  These fields acts as request modifiers, with semantics equivalent to the parameters on a programming language method invocation.  The request-headers are:  Accept-Charset, Authorization, Accept-Encoding, From, Host, If-Match.</li>
<li><em>Response-Header</em>: The response-header fields allow the server to pass additional information about the response which cannot be placed in the Status-Line.  These header fields give information about the server and about futher access to the resource identified by the Request-URI. The response-header are: Age, ETag, Location, Retry-After, Server, Vary, WWW-Authenticate etc.</li>
<li><em>Entity-Header</em>: Request and Response message MAY transfer an entity if not otherwise restricted by the request method or response status code.  Entity-Header fields define meta information about the entity-body or, if no body is present, about the resource identified by the request. Some of this meta information is OPTIONAL, some might be REQUIRED.  The entity-header includes: Content-Encoding, Content-Language, Content-Type, Expires, Last-Modified etc.</li>
</ol>
<p><strong>Status Code and Reason Phrase</strong></p>
<p>The Status-Code element is a 3-digit integer result code of the attempt to understand and satisfy the request. The Reason-Phrase is intended to give a short textual description of the Status-Code. The Status-Code is intended for use by automata and the Reason-Phrase is intended for the human user. The client is not required to examine or display the Reason- Phrase.</p>
<p>The first digit of the Status-Code defines the class of response. The last two digits do not have any categorization role. There are 5 values for the first digit:</p>
<ul>
<li>1xx: Informational - Request received, continuing process.</li>
<li>2xx: Success - The action was successfully received, understood, and accepted</li>
<li>3xx: Redirection - Further action must be taken in order to complete the request</li>
<li>4xx: Client Error - The request contains bad syntax or cannot be fulfilled</li>
<li>5xx: Server Error - The server failed to fulfill an apparently valid request</li>
</ul>
<p> </p>
<table border="0" width="100%">
<tbody>
<tr>
<td colspan="3" align="left" valign="top" bgcolor="#f5f5f5"><strong>Informational</strong></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top" bgcolor="#f5f5f5">100-199</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Silent Response Codes that signify that a request has been received and is currently being processed.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">100</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Continue</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A status code of 100 indicates that (usually the first) part of a request has been received without any problems, and that the rest of the request should now be sent.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">101</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Switching Protocols</td>
<td align="left" valign="top" bgcolor="#f5f5f5">HTTP 1.1 is just one type of protocol for transferring data on the web, and a status code of 101 indicates that the server is changing to the protocol it defines in the &#8220;Upgrade&#8221; header it returns to the client. For example, when requesting a page, a browser might receive a statis code of 101, followed by an &#8220;Upgrade&#8221; header showing that the server is changing to a different version of HTTP.</td>
</tr>
<tr>
<td colspan="3" align="left" valign="top" bgcolor="#f5f5f5"> </td>
</tr>
<tr>
<td colspan="3" align="left" valign="top" bgcolor="#f5f5f5"><strong>Successful Client Requests</strong></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top" bgcolor="#f5f5f5">200-299</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Silent codes that confirm that requests have completed successfully.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">200</td>
<td align="left" valign="top" bgcolor="#f5f5f5">OK</td>
<td align="left" valign="top" bgcolor="#f5f5f5">The 200 status code is by far the most common returned. It means, simply, that the request was received and understood and is being processed.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">201</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Created</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A 201 status code indicates that a request was successful and as a result, a resource has been created (for example a new page).</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">202</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Accepted</td>
<td align="left" valign="top" bgcolor="#f5f5f5">The status code 202 indicates that server has received and understood the request, and that it has been accepted for processing, although it may not be processed immediately.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">203</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Non-Authoritative Information</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A 203 status code means that the request was received and understood, and that information sent back about the response is from a third party, rather than the original server. This is virtually identical in meaning to a 200 status code.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">204</td>
<td align="left" valign="top" bgcolor="#f5f5f5">No Content</td>
<td align="left" valign="top" bgcolor="#f5f5f5">The 204 status code means that the request was received and understood, but that there is no need to send any data back.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">205</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Reset Content</td>
<td align="left" valign="top" bgcolor="#f5f5f5">The 205 status code is a request from the server to the client to reset the document from which the original request was sent. For example, if a user fills out a form, and submits it, a status code of 205 means the server is asking the browser to clear the form.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">206</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Partial Content</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A status code of 206 is a response to a request for part of a document. This is used by advanced caching tools, when a user agent requests only a small part of a page, and just that section is returned.</td>
</tr>
<tr>
<td colspan="3" align="left" valign="top" bgcolor="#f5f5f5"> </td>
</tr>
<tr>
<td colspan="3" align="left" valign="top" bgcolor="#f5f5f5"><strong>Client Request Redirected</strong></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top" bgcolor="#f5f5f5">300-399</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A redirection is occurring from the original request.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">300</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Multiple Choices</td>
<td align="left" valign="top" bgcolor="#f5f5f5">The 300 status code indicates that a resource has moved. The response will also include a list of locations from which the user agent can select the most appropriate.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">301</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Moved Permanently</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A status code of 301 tells a client that the resource they asked for has permanently moved to a new location. The response should also include this location. It tells the client to use the new URL the next time it wants to fetch the same resource.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">302</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Found</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A status code of 302 tells a client that the resource they asked for has temporarily moved to a new location. The response should also include this location. It tells the client that it should carry on using the same URL to access this resource.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">303</td>
<td align="left" valign="top" bgcolor="#f5f5f5">See Other</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A 303 status code indicates that the response to the request can be found at the specified URL, and should be retrieved from there. It does not mean that something has moved - it is simply specifying the address at which the response to the request can be found.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">304</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Not Modified</td>
<td align="left" valign="top" bgcolor="#f5f5f5">The 304 status code is sent in response to a request (for a document) that asked for the document only if it was newer than the one the client already had. Normally, when a document is cached, the date it was cached is stored. The next time the document is viewed, the client asks the server if the document has changed. If not, the client just reloads the document from the cache.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">305</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Use Proxy</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A 305 status code tells the client that the requested resource has to be reached through a proxy, which will be specified in the response.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">307</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Temporary Redirect</td>
<td align="left" valign="top" bgcolor="#f5f5f5">307 is the status code that is sent when a document is temporarily available at a different URL, which is also returned. There is very little difference between a 302 status code and a 307 status code. 307 was created as another, less ambiguous, version of the 302 status code.</td>
</tr>
<tr>
<td colspan="3" align="left" valign="top" bgcolor="#f5f5f5"> </td>
</tr>
<tr>
<td colspan="3" align="left" valign="top" bgcolor="#f5f5f5"><strong>Client Request Errors</strong></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top" bgcolor="#f5f5f5">400-499</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Request is incomplete for some reason.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">400</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Bad Request</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A status code of 400 indicates that the server did not understand the request due to bad syntax.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">401</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Unauthorised</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A 401 status code indicates that before a resource can be accessed, the client must be authorised by the server.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">402</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Payment Required</td>
<td align="left" valign="top" bgcolor="#f5f5f5">The 402 status code is not currently in use, being listed as &#8220;reserved for future use&#8221;.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">403</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Forbidden</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A 403 status code indicates that the client cannot access the requested resource. That might mean that the wrong username and password were sent in the request, or that the permissions on the server do not allow what was being asked.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">404</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Not Found</td>
<td align="left" valign="top" bgcolor="#f5f5f5">The best known of them all, the 404 status code indicates that the requested resource was not found at the URL given, and the server has no idea how long for.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">405</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Method Not Allowed</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A 405 status code is returned when the client has tried to use a request method that the server does not allow. Request methods that are allowed should be sent with the response (common request methods are POST and GET).</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">406</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Not Acceptable</td>
<td align="left" valign="top" bgcolor="#f5f5f5">The 406 status code means that, although the server understood and processed the request, the response is of a form the client cannot understand. A client sends, as part of a request, headers indicating what types of data it can use, and a 406 error is returned when the response is of a type not in that list.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">407</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Proxy Authentication Required</td>
<td align="left" valign="top" bgcolor="#f5f5f5">The 407 status code is very similar to the 401 status code, and means that the client must be authorised by the proxy before the request can proceed.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">408</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Request Timeout</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A 408 status code means that the client did not produce a request quickly enough. A server is set to only wait a certain amount of time for responses from clients, and a 408 status code indicates that time has passed.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">409</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Conflict</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A 409 status code indicates that the server was unable to complete the request, often because a file would need to be editted, created or deleted, and that file cannot be editted, created or deleted.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">410</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Gone</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A 410 status code is the 404&#8217;s lesser known cousin. It indicates that a resource has permanently gone (a 404 status code gives no indication if a resource has gine permanently or temporarily), and no new address is known for it.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">411</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Length Required</td>
<td align="left" valign="top" bgcolor="#f5f5f5">The 411 status code occurs when a server refuses to process a request because a content length was not specified.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">412</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Precondition Failed</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A 412 status code indicates that one of the conditions the request was made under has failed.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">413</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Request Entity Too Large</td>
<td align="left" valign="top" bgcolor="#f5f5f5">The 413 status code indicates that the request was larger than the server is able to handle, either due to physical constraints or to settings. Usually, this occurs when a file is sent using the POST method from a form, and the file is larger than the maximum size allowed in the server settings.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">414</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Request-URI Too Long</td>
<td align="left" valign="top" bgcolor="#f5f5f5">The 414 status code indicates the the URL requested by the client was longer than it can process.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">415</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Unsupported Media Type</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A 415 status code is returned by a server to indicate that part of the request was in an unsupported format.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">416</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Requested Range Not Satisfiable</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A 416 status code indicates that the server was unable to fulfill the request. This may be, for example, because the client asked for the 800th-900th bytes of a document, but the document was only 200 bytes long.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">417</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Expectation Failed</td>
<td align="left" valign="top" bgcolor="#f5f5f5">The 417 status code means that the server was unable to properly complete the request. One of the headers sent to the server, the &#8220;Expect&#8221; header, indicated an expectation the server could not meet.</td>
</tr>
<tr>
<td colspan="3" align="left" valign="top" bgcolor="#f5f5f5"> </td>
</tr>
<tr>
<td colspan="3" align="left" valign="top" bgcolor="#f5f5f5"><strong>Server Errors</strong></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top" bgcolor="#f5f5f5">500-599</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Errors have occurred in the server itself.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">500</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Internal Server Error</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A 500 status code (all too often seen by Perl programmers) indicates that the server encountered something it didn&#8217;t expect and was unable to complete the request.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">501</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Not Implemented</td>
<td align="left" valign="top" bgcolor="#f5f5f5">The 501 status code indicates that the server does not support all that is needed for the request to be completed.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">502</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Bad Gateway</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A 502 status code indicates that a server, while acting as a proxy, received a response from a server further upstream that it judged invalid.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">503</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Service Unavailable</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A 503 status code is most often seen on extremely busy servers, and it indicates that the server was unable to complete the request due to a server overload.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">504</td>
<td align="left" valign="top" bgcolor="#f5f5f5">Gateway Timeout</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A 504 status code is returned when a server acting as a proxy has waited too long for a response from a server further upstream.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#f5f5f5">505</td>
<td align="left" valign="top" bgcolor="#f5f5f5">HTTP Version Not Supported</td>
<td align="left" valign="top" bgcolor="#f5f5f5">A 505 status code is returned when the HTTP version indicated in the request is no supported. The response should indicate which HTTP versions are supported.</td>
</tr>
</tbody>
</table>
<p> To check the headers visit: <a title="HTTP HTTPS Header Check" href="http://tools.freenetsolutions.com/web_server_header.php" target="_blank"><strong>HTTP / HTTPS Header Check</strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://technology.freenetsolutions.com/2008/05/http-header-and-server-response-codes/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Shorthand CSS Properties</title>
		<link>http://technology.freenetsolutions.com/2007/05/shorthand-css-properties/</link>
		<comments>http://technology.freenetsolutions.com/2007/05/shorthand-css-properties/#comments</comments>
		<pubDate>Tue, 08 May 2007 07:49:21 +0000</pubDate>
		<dc:creator>infoweb</dc:creator>
		
		<category><![CDATA[Website Formatting]]></category>

		<category><![CDATA[CSS]]></category>

		<category><![CDATA[CSS Optimization]]></category>

		<category><![CDATA[CSS Properties]]></category>

		<guid isPermaLink="false">http://technology.freenetsolutions.com/?p=4</guid>
		<description><![CDATA[The CSS can be made clean with removing the properties names as mentioned below.  This can help in reducing the size of CSS in the process of development of website.
Font
Use:
font: 1em/1.5em bold italic serif
…instead of
font-size: 1em; line-height: 1.5em; font-weight: bold; font-style: italic; font-family: serif
 
Border
Use:
border: 1px black solid
…instead of
border-width: 1px; border-color: black; border-style: solid
Background
Use:

background: #fff url(image.gif) [...]]]></description>
			<content:encoded><![CDATA[<p>The CSS can be made clean with removing the properties names as mentioned below.  This can help in reducing the size of CSS in the process of development of website.</p>
<h2>Font</h2>
<p>Use:</p>
<blockquote><p>font: 1em/1.5em bold italic serif<br />
…instead of<br />
font-size: 1em; <span>line-height: 1.5em;</span> <span>font-weight: bold;</span> <span>font-style: italic;</span> <span>font-family: serif</span></p></blockquote>
<p> <span id="more-4"></span></p>
<h2>Border</h2>
<p>Use:</p>
<blockquote><p>border: 1px black solid<br />
…instead of<br />
<span>border-width: 1px;</span> <span>border-color: black;</span> <span>border-style: solid</span></p></blockquote>
<h2>Background</h2>
<p>Use:</p>
<blockquote>
<p class="coding">background: #fff url(image.gif) no-repeat top left<br />
…instead of<br />
<span>background-color: #fff;</span> <span>background-image: url(image.gif);</span> <span>background-repeat: no-repeat;</span> <span>background-position: top left;</span></p>
</blockquote>
<h2>Margin, padding, border</h2>
<p>Use:</p>
<blockquote>
<p class="coding">margin: 2px 1px 3px 4px <strong>(top, right, bottom, left)<br />
</strong>…instead of<br />
<span>margin-top: 2px;</span> <span>margin-right: 1px;</span> <span>margin-bottom: 3px;</span> <span>margin-right: 4px</span></p>
</blockquote>
<p>Use:</p>
<blockquote>
<p class="coding">margin: 5em 1em 3em <strong>(top, left and right, bottom)<br />
</strong>…instead of<br />
<span>margin-top: 5em;</span> <span>margin-bottom: 1em;</span> <span>margin-right: 1em;</span> <span>margin-right: 4em</span></p>
</blockquote>
<p>Use:</p>
<blockquote>
<p class="coding">margin: 5% 1% <strong>(top and bottom, left and right)<br />
</strong>…instead of<br />
<span>margin-top: 5%;</span> <span>margin-bottom: 5%;</span> <span>margin-right: 1%;</span> <span>margin-right: 1%</span></p>
</blockquote>
<p>These rules can be applied to <span class="code">margin</span>, <span class="code">border</span> and <span class="code">padding</span>.</p>
]]></content:encoded>
			<wfw:commentRss>http://technology.freenetsolutions.com/2007/05/shorthand-css-properties/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Code Optimization</title>
		<link>http://technology.freenetsolutions.com/2007/05/php-code-optimization/</link>
		<comments>http://technology.freenetsolutions.com/2007/05/php-code-optimization/#comments</comments>
		<pubDate>Sat, 05 May 2007 06:11:41 +0000</pubDate>
		<dc:creator>infoweb</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Php code]]></category>

		<category><![CDATA[PHP Optimization]]></category>

		<category><![CDATA[PHP Performance]]></category>

		<guid isPermaLink="false">http://technology.freenetsolutions.com/?p=3</guid>
		<description><![CDATA[I have found the post by Reinhold Webber, which provide good techniques and methods for PHP performance and optimization.   I have tried to add more explanation to the points posted by Reinhold Webber.

If a method can be static, declare it static. Speed improvement is by a factor of 4.
echo is faster than print and print_r.
Use echo&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>I have found the post by <a rel="external,nofollow" href="http://reinholdweber.com/?p=3" target="_blank">Reinhold Webber</a>, which provide good techniques and methods for PHP performance and optimization.   I have tried to add more explanation to the points posted by Reinhold Webber.</p>
<ol>
<li>If a method can be static, declare it static. Speed improvement is by a factor of 4.</li>
<li>echo is faster than print and print_r.</li>
<li>Use echo&#8217;s multiple parameters instead of string concatenation.</li>
<li>Set the maxvalue for your for-loops before and not in the loop.</li>
<li>Unset your variables to free memory, especially large arrays.</li>
<li>Avoid magic like __get, __set, __autoload.<span id="more-3"></span></li>
<li>require_once()/include_once are expensive., use require/include instead.</li>
<li>Use full paths in includes and requires, less time spent on resolving the OS paths. Always use full path file path when opening files, to avoid expensive normalization of the file&#8217;s path. This is also important even if you use opcode cache, since the paths of includes and normal files will still need to be resolved.</li>
<li>If you need to find out the time when the script started executing, INSERT:CONTENT:END SERVER['REQUEST_TIME'] is preferred to time()</li>
<li>See if you can use strncasecmp, strpbrk and stripos instead of regex</li>
<li>str_replace is faster than preg_replace, but strtr is faster than str_replace by a factor of 4</li>
<li>If the function, such as string replacement function, accepts both arrays and single characters as arguments, and if your argument list is not too long, consider writing a few redundant replacement statements, passing one character at a time, instead of one line of code that accepts arrays as search and replace arguments.</li>
<li>It&#8217;s better to use select statements than multi if, else if, statements.</li>
<li>Error suppression with @ is very slow.</li>
<li>Turn on apache&#8217;s mod_deflate.</li>
<li>Close your database connections when you&#8217;re done with them.</li>
<li>$row['id'] is 7 times faster than $row[id]</li>
<li>Error messages are expensive.  Do use error_reporting (E_ALL) during debug.</li>
<li>Do not use functions inside of for loop, such as for ($x=0; $x &lt; count($array); $x) The count() function gets called each time.</li>
<li>Incrementing a local variable in a method is the fastest. Nearly the same as calling a local variable in a function.</li>
<li>Incrementing a global variable is 2 times slow than a local var.</li>
<li>Incrementing an object property (eg. <samp>$this-&gt;prop++</samp>) is 3 times slower than a local variable.</li>
<li>Incrementing an undefined local variable is 9-10 times slower than a pre-initialized one.</li>
<li>Just declaring a global variable without using it in a function also slows things down (by about the same amount as incrementing a local var). PHP probably does a check to see if the global exists.</li>
<li>Method invocation appears to be independent of the number of methods defined in the class because I added 10 more methods to the test class (before and after the test method) with no change in performance.</li>
<li>Methods in derived classes run faster than ones defined in the base class.</li>
<li>A function call with one parameter and an empty function body takes about the same time as doing 7-8 <samp>$localvar++</samp> operations. A similar method call is of course about 15 <samp>$localvar++</samp> operations.</li>
<li>Surrounding your string by &#8216; instead of &#8221; will make things interpret a little faster since php looks for variables inside &#8220;&#8230;&#8221; but not inside &#8216;&#8230;&#8217;. Of course you can only do this when you don&#8217;t need to have variables in the string.</li>
<li>When echoing strings it&#8217;s faster to separate them by comma instead of dot. Note: This only works with echo, which is a function that can take several strings as arguments.</li>
<li>A PHP script will be served at least 2-10 times slower than a static HTML page by Apache. Try to use more static HTML pages and fewer scripts.</li>
<li>Your PHP scripts are recompiled every time unless the scripts are cached. Install a PHP caching product to typically increase performance by 25-100% by removing compile times.<br />
You can try these products:<br />
- <em>ionCube PHP Accelerator</em>: This has the most recognizable &#8220;brand&#8221;, and some hosting providers even offer it, but it&#8217;s offered only in binary form and the license seems internationally ambiguous (not free).<br />
-<em>Turck MMCache for PHP</em>: Has a good performance, and is GPL&#8217;d, but development appears to have ended way back in 2003.<br />
-<em>afterBURNDER * Cache</em>: A tool to speed up web applications.  This project is also dead now.<br />
- <em>Zend Platform Performance Suite</em>: A commercial suite that enchanced multi-layered caching, monitoring of PHP, Java, Apache &amp; HTTP etc.<br />
- <em>APC: Alternative PHP Cache</em>: APC is a free, open, and robust framework for caching and optimizing PHP intermediate code.</li>
<li>Cache as much as possible. Use memcached - memcached is a high-performance memory object caching system intended to speed up dynamic web applications by alleviating database load. OP code caches are useful so that your script does not have to be compiled on every request</li>
<li>When working with strings and you need to check that the string is either of a certain length you&#8217;d understandably would want to use the strlen() function. This function is pretty quick since it&#8217;s operation does not perform any calculation but merely return the already known length of a string available in the zval structure (internal C struct used to store variables in PHP). However because strlen() is a function it is still somewhat slow because the function call requires several operations such as lowercase &amp; hashtable lookup followed by the execution of said function. In some instance you can improve the speed of your code by using an isset() trick.<br />
Example:</li>
<blockquote><p><code>if (strlen($foo) &lt; 5) { echo "Foo is too short"; }<br />
vs.<br />
if (!isset($foo{5})) { echo "Foo is too short"; }</code></p></blockquote>
<p>Calling isset() happens to be faster then strlen() because unlike strlen(), isset() is a language construct and not a function meaning that it&#8217;s execution does not require function lookups and lowercase. This means you have virtually no overhead on top of the actual code that determines the string&#8217;s length.</p>
<li>When incrementing or decrementing the value of the variable <samp>$i++</samp> happens to be a tad slower then <samp>++$i</samp>. This is something PHP specific and does not apply to other languages, so don&#8217;t go modifying your C or Java code thinking it&#8217;ll suddenly become faster, it won&#8217;t. <samp>++$i</samp> happens to be faster in PHP because instead of 4 opcodes used for <samp>$i++</samp> you only need 3. Post incrementation actually causes in the creation of a temporary var that is then incremented. While pre-incrementation increases the original value directly. This is one of the optimization that opcode optimized like Zend&#8217;s PHP optimizer. It is a still a good idea to keep in mind since not all opcode optimizers perform this optimization and there are plenty of ISPs and servers running without an opcode optimizer.</li>
<li>Not everything has to be OOP, often it is too much overhead, each method and object call consumes a lot of memory.</li>
<li>Do not implement every data structure as a class, arrays are useful, too</li>
<li>Don&#8217;t split methods too much, think, which code you will really re-use</li>
<li>You can always split the code of a method later, when needed</li>
<li>Make use of the countless predefined functions</li>
<li>If you have very time consuming functions in your code, consider writing them as C extensions</li>
<li>Profile your code. A profiler shows you, which parts of your code consumes how many time. The Xdebug debugger already contains a profiler. Profiling shows you the bottlenecks in overview</li>
<li>mod_gzip which is available as an Apache module compresses your data on the fly and can reduce the data to transfer up to 80%</li>
<li><a class="nw" href="http://phplens.com/lens/php-book/optimizing-debugging-php.php" target="_blank">Excellent Article</a> about optimizing php by John Lim</li>
</ol>
<p>In the above in would like to include few of my experience and few of point which i have learnt from internet. </p>
<ul>
<li>PHP configuration directives make significant impact on performance of PHP.<br />
- Make sure that <em>register_globals</em> is disabled.<br />
- Disable <em>magic_quotes_*</em> directives.<br />
- Turn of <em>expose_php</em>.<br />
- Turn off <em>register_argc_argv</em> for non-cli SAPIs.<br />
- Unless absolutely necessary do not enable <em>always_populate_raw_post_data</em>.</li>
<li>PHP supports zlib compression for cached pages.</li>
<li>Session Optimization<br />
- Don&#8217;t used <em>session.auto_start</em>.<br />
- Do not enable <em>session.use_trans_sid</em>.<br />
- Whenever possible set <em>session.cache_limiter</em> to <em>private_no_expire</em>.<br />
- Assign each vhost it&#8217;s own sessions directory.<br />
- If possible avoid automatic garbage collection.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://technology.freenetsolutions.com/2007/05/php-code-optimization/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
