Friday, October 25, 2013

Website Speed Optimization for Online Performance - HTACCESS Code

GZIP Code Working

# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript

AddOutputFilterByType DEFLATE application/x-javascript

EXPIRE HEADER Code Working

<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A600
ExpiresByType image/x-icon A2592000
ExpiresByType application/x-javascript A604800
ExpiresByType text/css A604800
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/ico A2592000
ExpiresByType text/plain A86400
ExpiresByType application/x-shockwave-flash A2592000
ExpiresByType video/x-flv A2592000
ExpiresByType application/pdf A2592000
ExpiresByType text/html A600
</IfModule>

E-Tags Code Working

FileETag MTime Size
<ifmodule mod_expires.c>
  <filesmatch "\.(jpg|gif|png|css|js)$">
       ExpiresActive on
       ExpiresDefault "access plus 1 year"
   </filesmatch>
</ifmodule>

NON-www to www

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Removing /index.html

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php|html) [NC]
RewriteRule ^index\.php$ http://www.yourdomain.com/ [R=301,L]


Removing /index.php

RewriteBase /
# redirect html pages to the root domain

RewriteRule ^index\.php$ / [NC,R,L]

301 Redirect for Renamed Pages

redirect 301 /old/old.htm http://www.you.com/new.htm


Reference

GZIP - http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/#postcomment
Expire Header - http://www.tipsandtricks-hq.com/how-to-add-far-future-expires-headers-to-your-wordpress-site-1533

E-Tags  - http://stuntsnippets.com/etags-htaccess/

Removing Index.php - http://www.search-friendly-web-design.com/joomla/16-joomla-seo-htaccess-301-redirects-and-apache-modrewrite

Adding Expires headers for FONTS

<IfModule mod_deflate.c>
    #The following line is enough for .js and .css
    AddOutputFilter DEFLATE js css
    Addtype font/opentype .otf
    Addtype font/eot .eot
    Addtype font/truetype .ttf
    #The following line also enables compression by file content type, for the following list of Content-Type:s
    AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml

    #The following lines are to avoid bugs with some browsers
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

How to enable keep-alive

<ifModule mod_headers.c>
    Header set Connection keep-alive
</ifModule>

Render blocking CSS

Move the Blocking CSS below the </html>

</html>

<link href="css/style.css" rel="stylesheet" type="text/css">

No comments:

Post a Comment