Thursday, September 21, 2017

speed up Magento using .htaccess file

Speed Magento with .htaccess file

1) Enable Gzip Compression For Magento

Gzip is a method of compressing files (reducing file’s size) for faster network transfers. In your htaccess file, find.  #php_flag zlib.output_compression on  and un-comment it to enable Gzip Compression

2) Compressing CSS and JavaScript files
Compressing CSS and JavaScript files is important to speed your Magento site, we can enable compression for CSS and Java files by adding the following lines to .htaccess file:

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
</IfModule>

Enable Expires Headers
Expire header is used here to indicate how long browser should store files for caching. Generally, we use expire headers for images file only but for Magento, we should apply expire header for all elements like script, styles or flash.

############################################
## Add Expires header to Magento - by Magentoexplorer.com
## http://developer.yahoo.com/performance/rules.html#expires
    <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
    ExpiresActive On
    ExpiresDefault "access plus 1 year"

Disable ETags
Entity tags (ETags) help web servers and browsers use to determine if the component in the browser’s cache matches the one on the origin serverETages allow browsers to validate cached page. We can disable eTags to improve performance:
FileETag none
Disable some unwanted modules

No comments:

Post a Comment