Magento tweak .htaccess for performance optimization
Tweak .htaccess for performance optimization in Magento. It will not sky rocket your website, but will show notable improvement. The default Magento .htaccess comes with performance optimization, but commented by default. I will show you here which lines to uncomment and improve the performance.
Compressing web pages with mod_deflate
The mod_deflate module allows the Apache2 web service to compress files and deliver them to browser that can handle them. With mod_deflate you can compress HTML, text or XML files by upto 70% of their original sizes! Thus, saving you server traffic and speeding up page loads.
Check your .htaccess file for below code, I have removed hashes before few lines to uncomment them for performance.
<IfModule mod_deflate.c> | |
############################################ | |
## enable apache served files compression | |
## http://developer.yahoo.com/performance/rules.html#gzip | |
# Insert filter on all content | |
SetOutputFilter DEFLATE | |
# Insert filter on selected content types only | |
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript | |
# Netscape 4.x has some problems... | |
BrowserMatch ^Mozilla/4 gzip-only-text/html | |
# Netscape 4.06-4.08 have some more problems | |
BrowserMatch ^Mozilla/4\.0[678] no-gzip | |
# MSIE masquerades as Netscape, but it is fine | |
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html | |
# Don't compress images | |
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary | |
# Make sure proxies don't deliver the wrong content | |
Header append Vary User-Agent env=!dont-vary | |
</IfModule> |
Enabling expires header with mod_expires
Make browser cache static files with Apache2’s mod_expires module.
<IfModule mod_expires.c> | |
############################################ | |
## Add default Expires header | |
## http://developer.yahoo.com/performance/rules.html#expires | |
ExpiresActive On | |
ExpiresDefault "access plus 1 year" | |
</IfModule> |
Leave a comment
Welcome to my Blog
Certifications
Honor
Recognition
Contributions
Categories
- Apache (2)
- ChatGPT (1)
- Domain name (2)
- eCommerce (2)
- htaccess (1)
- Humor (3)
- Instagram API (1)
- jQuery (4)
- JSON (1)
- Linux (10)
- Magento (142)
- Magento admin (58)
- Magento Certification (5)
- Magento error (13)
- Magento frontend (68)
- Magento Imagine (2)
- Magento Interview (5)
- Magento Master (2)
- Magento2 (10)
- Mobile (1)
- MySQL (7)
- OpenAI (1)
- OroCRM (2)
- Performance (2)
- PHP (8)
- Prototype JS (3)
- Security (4)
- Wordpress (3)
- XML (2)