How to speed up your site with Magento .htaccess file


Slow website load speed is a persistent problem that every Magento store owner/developer wants to get rid of. As you know Magento is a heavy opensource platform as it has many powerful features for running a full-pledged eCommerce website.

There are many ways to improve Magento website’s load speed. For example: running on a high performance Magento hosting/server, optimize code of Magento themes or modules or enable cache or compression for Magento. In this tutorial, I will guide you how to improve Magento site’s speed by enhancing .htaccess file and some other tweaks in Magento admin section.

Before we start, you can check your magento store’s speed using Google pagespeed insight After implementing the following tweak, check it once again to see the result. This is what I get for after making some tweaks with .htaccess file.

magento explorer performance

Speed Magento with .htaccess

Before making any changes to .htaccess file, remember to save a backup of the original file. In case you lose this file or there’s no file in your Magento folder, you can always download original file at by selecting the version you are using and download Magento installation package, you can find original .htaccess file after unzipping the package.

Now let’s speed up your Magento site with some tweaks in .htaccess file.

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

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:

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.

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:

Some other tweaks in Magento admin section

Combine CSS and JS files

You can merge CSS and Javascript file into one file to reduce number of HTTP requests to speed up your website. Magento has a section in admin panel to help you with this. Go to “System” > “Configuration” >“Advanced” > “Developer.” and select Merge JavaScript files and Merge CSS Files

magento speed tweak

Enable Flat Catalog

The option Enable Flat Catalog is used to merge product data into 1 table, which will improving MYSQL database performance. You should enable Flat Catalog if your store have 500+ products. To enable Flat Catalog, go to System > Configuration > Catalog, in “use Flat Catalog Category” and “use Flat Catalog Product” select yes.

magento flat product enable

Fianlly, clear Magento cache to apply changes.

Enable Cache

Enable cache for Magento so that the browser will not load static components next time users visit your site. Go to System > Cache Managemen and do as below

magento speed tweak enable cache


There are many steps need to be taken to improve your Magento site’s load speed. I will continue sharing ideas about this topic in the next article in Magento SEO section, let me know if you have any question or ideas.

Rate this post


About Author

Daniel is a Magento developer with 5 years of experience with customizing Magento extensions, Magento templates. He's main author at Magento explorer

1 Comment

  1. Thank you for your post!
    There is also a very useful extension to increase Magento website speed effectively called Defer Javascript extension (
    by deferring JavaScript files loading after all HTML and CSS files loading so that a web page will render HTML and CSS in advance.
    – Automatically defer parsing of JavaScript till the last moment after all HTML and CSS loading
    – Reduce loading time and speed up Magento sites

Leave A Reply