Monthly Archives: November 2008

Speed up your web pages with YSlow

First download/install firefox add-ons Firebug and YSlow

1. Make Fewer HTTP Requests

Combined files are a way to reduce the number of HTTP requests.
CSS Sprites are the preferred method for reducing the number of image requests.
Image map combine multiple images into a single image.

2. Use a Content Delivery Network

Intermediary caching is cache between the browser and the server, so use CDN like facebook

3. Add an Expires Header

For static components: implement “Never expire” policy by setting far future Expires header.
For dynamic components: use an appropriate Cache-Control header to help the browser with conditional.

Expires: how long the web content cacheable.
max-age: the browser will request the new content after the age limit.

<FilesMatch “\.(jpg|jpeg|png|gif|swf|css|js|ico|pdf)$”>
Header add “Expires” “Mon, 15 Nov 2020 00:00:00 GMT”
Header add “Cache-Control” “max-age=31536000”

4. Gzip Components

<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*

5. Put CSS at the Top

6. Move Scripts to the Bottom

7. Avoid CSS Expressions

background-color: expression( (new Date()).getHours()%2 ? “#B8D4FF” : “#F08A00” );

8. Make JavaScript and CSS External

9. Reduce DNS Lookups

10. Minify JavaScript

<IfModule mod_rewrite.c>
RewriteRule ^css/(.*\.css) combine.php?type=css&files=$1
RewriteRule ^js/(.*\.js) combine.php?type=js&files=$1

11. Avoid Redirects

12. Remove Duplicate Scripts

13. Configure ETags

This is the unique identifier for comparing cached files.

<FilesMatch “\.(gif|jpg|jpeg|png|swf|css|js|html?|xml|txt)$”>
FileETag none

More page optimization techniques are here below:

Make Ajax Cacheable
Flush the Buffer Early
Use GET for AJAX Requests
Reduce the Number of DOM Elements
Split Components Across Domains
Minimize the Number of iframes
No 404s
Reduce Cookie Size
Use Cookie-free Domains for Components
Choose <link> over @import
Optimize Images
Don’t Scale Images in HTML
Make favicon.ico Small and Cacheable
Keep Components under 25K

We can use Server Caching for higher level of caching your PHP.

Leave a comment

Posted by on November 15, 2008 in resources


Tags: ,

MySQL backup by command line

# mysqldump -u username -p databasename > filename.sql
Compress the .sql file with gzip:

#gzip filename.sql

# mysqldump --all-databases > all_databases.sql

# mysqldump --user=root \
> --password=sa --host=localhost \
> database > backup.sql

# mysqldump --user=root --password=sa --host=localhost  database > /var/www/backup.sql
Leave a comment

Posted by on November 13, 2008 in Linux, php, resources


Tags: , , ,

upload MySQL database – Command Line

Method 1 :

Create database for database_name and import the sql:
$ mysqladmin -p create database_name
$ mysql -p database_name < /var/www/html/database.sql

Method 2 :

Upload large SQL file by command line
copy SQL (database.sql) file to mysql/bin

D:……\>mysql -u root -p
Enter Password:

mysql>use database_name;
mysql>source database.sql

SQL ok.
Enjoy, may it will save someones some time!

Leave a comment

Posted by on November 13, 2008 in Linux, php, resources


Tags: , , ,

How to create .htpasswd?

Create .htpasswd file from commandLine:

# htpasswd -c  /var/www/html/.htpasswd sandeep
New password:
Re-type new password:
Updating password for user sandeep

Add these lines to .htaccess file

AuthType basic
AuthName “Ooops! Temporarily Under Construction…”
AuthUserFile /var/www/html/.htpasswd
AuthGroupFile /dev/null
Require valid-user # password prompt for everyone else
Order Deny,Allow
Deny from all
Allow from # Your, the developers IP address
Allow from # css/xhtml check
Allow from # Allows google to crawl your pages
Satisfy Any # no password required if host/ip is Allowed

Leave a comment

Posted by on November 13, 2008 in Linux, php


Tags: , , , ,

Amazon S3


Posted by on November 7, 2008 in Uncategorized


Tags: , , , ,