Thursday, 24 July 2014

Trick Accelerating Access Time Website

Access time shorter website can improve the comfort of the visitors, so that they endure to spend time on the website. For more, here are his tricks:

 

   1.  Reducing the number of HTTP Requests.  

Each file requested to the server it is a request .Artinya number of files in a request to the webserver   should be reduced. In addition to reducing the number of files we can also cache the file so that we can indirectly reduce HTTP rquest, since files obtained directly from the browser cache. If you are using apache then can use the module to mencache mod_expire such as image files, swf or website contents. Here is how to menggaktifkan mod_expire.LoadModule expires_module modules / mod_expires.so

     Once activated then we just create an htaccess file to mencache image, swf and JavaScripts for 1 month using mod_expire.
   
ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType application/x-Shockwave-Flash A2592000
 
     If you have some Javascript files and CSS files should be used as one of the js and css files only.

     2. Using a Content Delivery Network  

CDN usage can actually help speed up the performance of our website. We can use https://www.cloudflare.com/ if you want to use a CDN for free

    3. Adding Expiry Expires Header tags  


Adding Expiry Expires Header tags will help the browser to recognize where the content should be in the cache and no. Do not get when we do an update on client therapy unreadable because the load is stored in the cache. We can add expires headers in HTTP headers.

 
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past

     4. Gzip Gzip Components Components The working principle 

Gzip Gzip Components Components The working principle is to compress the output will be sent to the browser, so the size of the data sent to be smaller. Browser used must have the ability to decompress. Now the average of all browsers already support this feature. To enable this feature we should add the following configuration in our server

    
LoadModule deflate_module modules/mod_deflate.so
	

     Once enabled, you can use the configuration beriku add in htaccess files.  
    
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-javascript
   
  or can also do it on the PHP side using ob_start ("ob_gzhandler") example:

   
//gzipjs.php
ob_start("ob_gzhandler");
header("Content-type: text/javascript; charset: UTF-8");
header("Cache-Control: must-revalidate");
$offset = 60 * 60 * 24 * 3;
$ExpStr = "Expires: " .
gmdate("D, d M Y H:i:s",
time() + $offset) . " GMT";
header($ExpStr);
include(urldecode($_GET['js']));

     5. Put the script at the top of the Placing CSS css code in the header can speed up loading of the website on css because usually there are other components such as the image will be loaded, so the next put up can make a website appear in the progressive.
 
     6. Moving down javascript script problems that arise when they are above javascript block download another script so that all scripts downloaded serially.

     7. Avoiding the use of CSS Expressions CSS expressions is one way to display the css dynamically. example
    
background-color: expression
( (new Date()).getHours()%2 ? "#B8D4FF" : "#F08A00" ); 
 
     the code above will be executed berulang2 times so that it would interfere with the performance of the website.
     
     8. Reduce DNS lookups Reduce DNS lookups can speed up access .. so how redeeming the domain name the same for all the resources available on our website ..

     9. Minify JavaScript and CSS The idea was to get rid of all the useless characters in the code so that its size becomes smaller.

     10. Avoid Redirects Avoid using redirects the request because it will happen back and forth between the client and server

     11.  Discard the same Scripts If we have the same script, then please remove it because this script will still be loaded by the client so the client will weigh