Turbo für Ihre Webseite über die .htacess Datei
Um den Pagespeed einer Webseite zu erhöhen gibt es mittlerweile viele Plugins. Je nach angewendeten CMS lohnt es sich diese auch zu verwenden. Hat man kein CMS oder möchte aus anderen Gründen keines dieser Plugins verwenden, so kann man auch durch die Anpassung der .htaccess Datei einen Turbo für seine Webseiten zünden. Dieser Beitrag wird noch erweitert mit diversen Tipps.
Hier ein paar Einstellungen welche sinnvoll sind:
- Kombrimierung durch deflate
# Deflate Compression by FileType <IfModule mod_deflate.c> 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/atom_xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/x-shockwave-flash </IfModule>
- Cache Ablauf einen Wert zuweisen
# turns cache on for 2 month <IfModule mod_expires.c> ExpiresActive On ExpiresByType text/css "access plus 2 month" ExpiresByType text/javascript "access plus 2 month" ExpiresByType text/html "access plus 2 month" ExpiresByType application/javascript "access plus 2 month" ExpiresByType image/gif "access plus 2 month" ExpiresByType image/jpeg "access plus 2 month" ExpiresByType image/png "access plus 2 month" ExpiresByType image/x-icon "access plus 2 month" </IfModule> <ifmodule mod_headers.c> <filesmatch "\\.(ico|jpe?g|png|gif|swf)$"> Header set Cache-Control "max-age=2592000, public" </filesmatch> <filesmatch "\\.(css)$"> Header set Cache-Control "max-age=604800, public" </filesmatch> <filesmatch "\\.(js)$"> Header set Cache-Control "max-age=216000, private" </filesmatch> </ifmodule>
- Alternative (anstelle von deflate) Komprimierung mit gzip (funktioniert nicht auf allen Servern)
# gzip Compression if availiable <IfModule mod_gzip.c> mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_exclude mime ^image/.* mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* </IfModule>
In den nächsten Tagen werde ich diesen Artikel noch erweitern mit sinnvollen Plugins und Codes um Ihren Pagespeed zu erhöhen. Dabei werde ich ausführlich über folgende Dinge schreiben:
- Browser-Caching nutzen
- GZIP Komprimierung aktivieren
- Zeichensatz angeben
- CSS kombinieren
- Javascript kombinieren
- CSS minimieren
- ungenutzten CSS-Code vermeiden
- Bilder in CSS-Sprites kombinieren
- HTML (Quellcode) reduzieren
- Bilder optimieren
- Parallele Downloads – Ressourcen von Subdomain laden
- Bildabmessungen festlegen
- Anforderungsgröße minimieren
- Reihenfolge der Formate und Skripts optimieren
- Fehlerhafte Anforderungen vermeiden
- JavaScript später parsen
- Umleitungen/redirects minimieren
- Asynchrones Laden (CSS und JS Scripte)
- Sichtbare Inhalte priorisieren
- Webfonts optimieren