affiliate_link

Sunday, May 18, 2014

Ajax vs Query

AJAX is a technique to do an XMLHttpRequest (out of band Http request) from a web page to the server and send/retrieve data to be used on the web page. AJAX stands for Asynchronous Javascript And XML. It uses javascript to construct an XMLHttpRequest, typically using different techniques on various browsers.

According to Wikipedia
Ajax (Asynchronous JavaScript and XML)[1] is a group of interrelated Web development techniques used on the client-side to create asynchronous Web applications. With Ajax, Web applications can send data to, and retrieve data from, a server asynchronously (in the background) without interfering with the display and behavior of the existing page. Data can be retrieved using the XMLHttpRequest object. Despite the name, the use of XML is not required; JSON is often used instead (see AJAJ), and the requests do not need to be asynchronous.[2]
Ajax is not a single technology, but a group of technologies. HTML and CSS can be used in combination to mark up and style information. The DOM is accessed with JavaScript to dynamically display, and allow the user to interact with, the information presented. JavaScript and the XMLHttpRequest object provide a method for exchanging data asynchronously between browser and server to avoid full page reloads.
Ref: http://en.wikipedia.org/wiki/Ajax_(programming)

jQuery (website) is a javascript framework that makes working with the DOM easier by building lots of high level functionality that can be used to search and interact with the DOM. Part of the functionality of jQuery implements a high-level interface to do AJAX requests. jQuery implements this interface abstractly, shielding the developer from the complexity of multi-browser support in making the request.

SOAP vs REST Webservices

SOAP (Simple Object Access Protocol) and REST (Representational State Transfer) both are used as interfaces to the Web Services.

REST Advantages
1. Limited Bandwidth and Resources
2. Totally Stateless Operations
3. Caching Issues

SOAP Advantages
1. Reliable Messaging (SOAP 1.2 offers additional reliability and security)
2. Formal Contracts (Both provider and consumer have to agree on the exchange format)
3. Stateful Operations (Security, Transaction, Coordination)

Sunday, May 11, 2014

Htaccess tips

1. Make all your files extension .htm instead of .php

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^(.+)\.htm$ /$1.php [NC,L] 

2. Remove file extensions. for example www.website.com/page.php will show as www.website.com/page

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ /$1.php [L,QSA]

3. Force File Download
Instead of opening files in the web browser it forces these files types to download

<FilesMatch "\.(mov|mp3|jpg|pdf)$">
  ForceType application/octet-stream
  Header set Content-Disposition attachment
</FilesMatch>




Reference: http://wiki.dreamhost.com/Htaccess_tricks

Wednesday, July 18, 2012

Check a website in Google Cache

Use following URL

Replace mywebsite.com with the website url to check without http

http://webcache.googleusercontent.com/search?q=cache:mywebsite.com

Tuesday, July 17, 2012

Permanent (301) redirection in PHP

Following is the code for permanent (301) redirect using php.
Better approach is to use .htaccess but there are situations where .htaccess could not be used so using following code might help

@header("HTTP/1.1 301 Moved Permanently");
@header("location: http://www.mywebsite.com");

Additionally if you want to redirect your home page to always open using www. which might be usefull when using cookies or for SEO. Add an if condition to code 

if (!preg_match('/www\..*?/', $_SERVER['HTTP_HOST']))
{
    @header("HTTP/1.1 301 Moved Permanently");
    @header("location: http://www." . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
}

Monday, July 16, 2012

301 Redirect in classic ASP

<%
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://www.website.com/"
Response.End
%>


Above code is enough for Redirection but its better put a link because you never know a user might have turned off auto redirection

<table>
    <tr>
        <td align="center" width="100%">
            <h1>The page you are looking for has moved...</h1>
            We have recently updated our site and the page you are looking for has moved.
            Click <a href="http://www.website.com/">here</a> to continue
        </td>
    </tr>
</table>