Magento Optimisation for Apache Server

20.10.2014 Angelika Siczek
Of course there are a few key elements to focus on, such as OS software – it is highly recommended to use Linux, but it is not recommended to use Windows servers for Magento, the system will work, however, will be less efficient, it may cause problems with file permissions or some parts of the code. It is important to limit the number of services to the minimum necessary on the production server, to simultaneously reduce the number of processes. Using XFS and ReiserFS, configuring MaxClients settings – for better control the number of subprocesses.
optymalizacja magento

MAGENTO OPTIMIZATION – APACHE SERVER

While optimizing Magento, it is not recommended to use SymLinksIfOwnerMatc, it is better to use Options + FollowSymLinks + SymLinksIFOwnerMatch for individual directories. It’s a good idea to enable Apache deflate and header modules, which you can do with the following commands:
sudo a2enmod deflate
sudo a2enmod header
However, my favorite method is to optimize using the default .htaccess file included with Magento. With a few lines of code, we can achieve unbelievable performance increases.

TURNING OFF THE COMPREHENSIVE COMPRESSION

The following section includes the mod_deflate module for Apache, which compresses text, CSS, and javascript before they are sent to the browser. The result of this operation is less downloading quantity. In order to turn it off, you should simply uncomment the appropriate lines in the file.
############################################
## 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 application/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

TURNING OFF HEADINGS

Browsers use header expiration to determine how long the certain page components should be cached. Static elements such as images should have long expiration dates, however, expiration dates are also useful for other page components. To enable this functionality again, you must uncomment the corresponding line of code in the htaccess file.
############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires
ExpiresActive On
ExpiresDefault “access plus 1 year”

TURNING OFF ETAGS

Etags are a way for browsers to check the caching components of the entire site during subsequent visits. However, they can affect a significant slowdown of the page if they have not been implemented properly in the cluster. It’s best to just disable Etags to avoid slowing down the server. You can do this as follows in the htaccess file.
############################################
## If running in cluster environment, uncomment this
## http://developer.yahoo.com/performance/rules.html#etags
FileETag none
In addition to optimizing the htaccess file itself, it is also worth using the compilation of CSS and javascript files. You can do it in the administration panel in:
System -> Configuration -> Programmer -> Javascript settings change the option Connect Javascript files to yes,
System -> Configuration -> Programmer -> CSS settings we change the option Combine CSS files to yes.
It is also worth thinking about enabling a flat directory in the administration panel, which will optimize the execution of queries to the database.
Of course, it should be remembered that each store is different and sometimes it is not advisable to use any of the points indicated here for various reasons, all such situations should be recognized individually for a given implementation.
Be sure to also read other articles on how to optimize Magento for SEO.

News Digitized / Stay Informed

Since the beginning of 2022, we are part of Unity Group. Now, by signing up for our newsletter, you will be kept up to date with information from our entire organization.

    By submitting the form you agree to receiving a newsletter that is sent by Unity S.A. based in Wrocław. You can withdraw your consent at any time. Additional information about the processing of available details provided in the privacy policy.

    *Required

    Andrzej-kurs-programowania

    Andrzej Szylar

    Chief Executive Officer

    E-mail:

    a.szylar@global4net.com
    Magda2

    Magdalena Paczyńska-Kamienik

    HR Manager

    Aleksandra

    Aleksandra Bielawska-Clegg

    HR Business Partner

    E-mail:

    Michal

    Michał Duława

    New Business Developer

    E-mail:

    Katarzyna

    Katarzyna Zajchowska

    Marketing Partner

    E-mail: