Improve Webserver Performance

Es gibt eine Vielzahl von Möglichkeiten den Webserver zu tunen. Allerdings ist noch immer das beste wenn wir dem „Client sagen was er tun soll, also dem Browser. Leichter gesagt als getan? Genau das ist es 😉
Zum einen aktivieren wir 2 Modules unseres Webserver:

a2enmod expires
a2enmod deflate


Nun müssen wir das ganze natürlich noch etwas konfigurieren.
Hier die entsprechenden Apache-Einstellungen, die man entweder global im Apache einstellen kann, oder im entsprechenden vhost der Domain oder aber in der .htaccess-Datei speziell für Ordner. Ich habe mich für die globale Einstellung in /etc/apache2/apache2.conf entschieden


   # turn on the module for this directory
   ExpiresActive on
   # set default
   ExpiresDefault "access plus 24 hours"

   # cache common graphics
   ExpiresByType image/jpg "access plus 1 months"
   ExpiresByType image/gif "access plus 1 months"
   ExpiresByType image/jpeg "access plus 1 months"
   ExpiresByType image/png "access plus 1 months"

   # cache CSS
   ExpiresByType text/css "access plus 1 months"

   # cache other filetypes
   ExpiresByType text/javascript "access plus 1 months"
   ExpiresByType application/javascript "access plus 1 months"
   ExpiresByType application/x-shockwave-flash "access plus 1 months"

Nun können wir noch ein Teil des Contents auf unserem Server komprimieren. Auch hier habe ich mich wieder für die globale Einstellung unter /etc/apache2/apache2.conf entschieden.


   AddOutputFilterByType DEFLATE text/plain
   AddOutputFilterByType DEFLATE text/html
   AddOutputFilterByType DEFLATE text/xml
   AddOutputFilterByType DEFLATE text/css
   AddOutputFilterByType DEFLATE text/javascript
   AddOutputFilterByType DEFLATE application/xml
   AddOutputFilterByType DEFLATE application/xhtml+xml
   AddOutputFilterByType DEFLATE application/rss+xml
   AddOutputFilterByType DEFLATE application/javascript
   AddOutputFilterByType DEFLATE application/x-javascript
   AddOutputFilterByType DEFLATE application/x-shockwave-flash

   DeflateFilterNote Input input_info
   DeflateFilterNote Output output_info
   DeflateFilterNote Ratio ratio_info
   LogFormat '"%r" %s %{output_info}n/%{input_info}n (%{ratio_info}n%%)' deflate
   CustomLog /var/log/apache2/deflate_log deflate

Nun denkt ihr das war alles? Noch nicht ganz. Ich habe es getestet und muss sagen es klappt wirklich.
Pagespeed von Google installieren. Kann auch nie schaden für ein besseres Pageranking bei google.

wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_amd64.deb
dpkg -i mod-pagespeed-*.deb
apt-get -f install

Pagespeed aktualisiert sich nun auch direkt über aptitude mit und muss somit nicht weiter beachtet werden.