Magento – best magento htaccess for performance

.htaccessgzipmemoryperformance

we have installed several extensions and bits and pieces of code to optimize Magento htaccess. Now I see the code has gotte quite long and I am not sure this is all conflicting or supporting …

So this is what we have so far. What are the best settings?

############################################
## http://www.magentocommerce.com/wiki/groups/227/allowed_memory_size_exhausted  
## Increase memory limit according to Magento
php_value memory_limit 64M
php_value max_execution_time 18000

############################################
## enable resulting html compression of php output
php_flag zlib.output_compression on

############################################
## enable apache served files compression (not php, html/images/css/js
## http://developer.yahoo.com/performance/rules.html#gzip

<IfModule mod_deflate.c>
# 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>

############################################
## Enable keep-alives to reduce # http requests
## http://yoast.com/magento-performance-hosting/

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

############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires

<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 14 days"
</IfModule>

and as I understand the next improvement is moving all these rules in htaccess to the virtualhost configuration directives mentioned here:

http://markshust.com/2012/01/11/removing-htaccess-files-magento-and-moving-contents-apache-configuration

Best Answer

You could increase the memory_limit to the minimum recommended 256MB. Outside of that, there's no real performance improvement to be gained in editing your htaccess.

The best htaccess is not having one at all. Move and/or rewrite your rules into your vhost definition in Apache and disable overrides.

For highest performance use AllowOverride None everywhere in your filesystem.

Source: http://httpd.apache.org/docs/current/misc/perf-tuning.html#htaccess

Related Topic