2010/11/12

.htaccess Deflate

Filed under: Tips & Tricks — Tags: — admin @ 3:19 pm

To have your files deflated in apache you can add these lines to your .htassecc file.
Deflating files helps keeping transferring size small. Apache automatically pack the files and your browser unpacks it but the you can save lots of MB a year on transfer size. And it helps the site to load faster on slow connections. This is almost like gziping but deflating method is less CPU aggressive on apache server compared to gzip.

  1.  
  2. AddOutputFilterByType DEFLATE text/plain
  3. AddOutputFilterByType DEFLATE text/html
  4. AddOutputFilterByType DEFLATE text/xml
  5. AddOutputFilterByType DEFLATE text/php
  6. AddOutputFilterByType DEFLATE text/css
  7. AddOutputFilterByType DEFLATE application/xml
  8. AddOutputFilterByType DEFLATE application/xhtml+xml
  9. AddOutputFilterByType DEFLATE application/rss+xml
  10. AddOutputFilterByType DEFLATE application/javascript
  11. AddOutputFilterByType DEFLATE application/x-javascript

.htaccess Expiredate

Filed under: Tips & Tricks — Tags: — admin @ 3:12 pm

To put expiredate on your files you can put these lines to your .htaccess file.
It reduses loading time for your site.

  1. ExpiresActive On
  2.  
  3. ExpiresByType image/png "access plus 20 days"
  4. ExpiresByType image/jpg "access plus 50 days"
  5. ExpiresByType image/jpeg "access plus 50 days"
  6. ExpiresByType image/ico "access plus 10 month"
  7. ExpiresByType image/gif "access plus 30 days"
  8. ExpiresByType text/javascript "access plus 8 days"
  9. ExpiresByType application/javascript "access plus 8 days"
  10. ExpiresByType text/css "access plus 8 days"

.htaccess gzip

Filed under: Tips & Tricks — Tags: — admin @ 3:07 pm

To put gzip on files from apache server you have to add there lines to your .htaccess file.

  1.  
  2.   mod_gzip_on Yes
  3.   mod_gzip_dechunk Yes
  4.   mod_gzip_item_include file \.(html?|txt|css|js|php)$
  5.   mod_gzip_item_include handler ^cgi-script$
  6.   mod_gzip_item_include mime ^text/.*
  7.   mod_gzip_item_include mime ^application/x-javascript.*
  8.   mod_gzip_item_exclude mime ^image/.*
  9.   mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
© Alireza Balouch 2012 .