11 Aug 2013

Apache compression.

Compressing web pages on Apache server

Compress the web pages on Apache server, so the size of the files the client(browser) receives will be reduced (by almost 5 folds).

Follow the configuration to compress the file on apache server.

In the httpd/conf.d/vhosts.conf file in linux add the following lines

# DEFLATE by type - html, text, css, xml
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml
 

# DEFLATE by type - javascript 
AddOutputFilterByType DEFLATE application/x-javascript application/javascript text/javascript text/x-js text/x-javascript
 

# DEFLATE by extension
AddOutputFilter DEFLATE js css htm html xml

The above lines compresses the file types specified in the #ed lines only(js, css, html, htm, xml and its associated mime types).

This compresses only js, css, html, htm, xml files and its associated mime types. All others will be sent uncompressed.

This compresses for all browsers.

follow this for documentation http://httpd.apache.org/docs/2.2/mod/mod_deflate.html.


2 Aug 2013

Database Order by

DB related:


Order by:


1.The arguments for order by may not have to be in the select list can be in the sub queries of the select list.

2.Order by A,B,C : ordering of B will be done after ordering of A if the order of A is not disturbed, similarly to ordering of C also.

EX:In the below arrangement,

ABC
12000-1004000
-150002006000
15250-3005000

if I say "Order by A desc, B asc , c desc" in the query then the output will be
A               B               C
15200    -300        5000
12000    -100        4000
-15000    200        6000

if you see B column is not ordering in asc because if it orders in ascending then order of A will be disturbed, similarly for C also.