Betrieb & Hosting

TYPO3 Geschwindigkeit Optimierung

In einigen TYPO3-Installationen kommt es vor, dass die Seite (sehr) langsam lädt, ohne das die Logfiles irgendwelche Fehlermeldungen liefern. Hier kann eine Optimierung des Caches der Webseie helfen! Folgende Schritte sind möglich und wurden unter TYPO3 6.2.12 und TYPO3 6.2.13 getestet:

I. Typoscript Cache

Im Typoscript muss

config.no_cache = 1

mit dem Value 0 deaktiviert werden

II. Extension nc_staticfilecache

Extension nc_staticfilecache installieren und konfigurieren (siehe auch https://youtu.be/o40iBJ3q0EA )

II.a Timestamp ausgeben lassen

im Extension Manager kann Show generation timestamp signature [basic.showGenerationSignature] gesetzt werden. Dies hat zur Folge, dass richtig gecachte Seiten im Quelltext (Footer) mit Timestamp als Kommentar ausgegeben werden

II.b Chache Status prüfen

zusätzlich kann über den Menüpunkt „Info“ noch der Chache Status der einzelnen Seiten geprüft werden

III.c .htacces anpassen

#------------------------------------------------------------------------------
# beginning of static file cache ruleset

# Check if the requested file exists in the cache, otherwise default to index.html that
# set in an environment variable that is used later on
RewriteCond %{DOCUMENT_ROOT}/typo3temp/tx_ncstaticfilecache/%{HTTP_HOST}/%{REQUEST_URI} !-f
RewriteRule .* - [E=TX_NCSTATICFILECACHE_FILE:/index.html]

# Don't cache HTTPS traffic. You may choose to comment out this
# option if your site runs fully on https. If your site runs mixed, you will
# not want https traffic to be cached in the same typo3temp folder where it can
# be requested over http.
# Enable this if you use a mixed setup.
#RewriteCond %{HTTPS} off

# We only redirect URI's without query strings
RewriteCond %{QUERY_STRING} ^$

# It only makes sense to do the other checks if a static file actually exists.
RewriteCond %{DOCUMENT_ROOT}/typo3temp/tx_ncstaticfilecache/%{HTTP_HOST}/%{REQUEST_URI}%{ENV:TX_NCSTATICFILECACHE_FILE} -f

# NO frontend user is logged in. Logged in frontend users may see different
# information than anonymous users. But the anonymous version is cached. So
# don't show the anonymous version to logged in frontend users.
RewriteCond %{HTTP_COOKIE} !nc_staticfilecache [NC]

# Uncomment the following line if you use MnoGoSearch
#RewriteCond %{HTTP:X-TYPO3-mnogosearch} ^$

# We only redirect GET requests
RewriteCond %{REQUEST_METHOD} GET

# NO backend user is logged in. Please note that the be_typo_user cookie expires at the
# end of the browser session. If you have logged out of the TYPO3 backend and are expecting to see cached pages but don't. Please close this browser session first or remove the cookie manually or use another browser to hit your frontend.
RewriteCond %{HTTP_COOKIE} !be_typo_user [NC]

# Check for Ctrl Shift reload
RewriteCond %{HTTP:Pragma} !no-cache
RewriteCond %{HTTP:Cache-Control} !no-cache

# Rewrite the request to the static file.
RewriteRule .* typo3temp/tx_ncstaticfilecache/%{HTTP_HOST}/%{REQUEST_URI}%{ENV:TX_NCSTATICFILECACHE_FILE} [L]

# end of static file cache rule set
#------------------------------------------------------------------------------

III. Typo3script Kompression

config.compressJs = 1
config.compressCss = 1
config.concatenateJs = 1
config.concatenateCss = 1

IV. PHP Konfiguration anpassen

PHP teilt jedem Besucher Ihrer Webseiten mit, dass es am Rendern der Seite beteiligt war. Dies macht es im so genannten X-POWERED-Header.
In der php.ini den Eintrag expose_php suchen und setzen Sie den Eintrag auf Off.

 expose_php = Off 

Achtung: Für gewöhnlich muss Apache reload erfolgen

V.Browser Caching aktivieren

In .htaccess Datei einfügen

# Caching einrichten
FileETag MTime Size

ExpiresActive On
ExpiresByType text/css "access plus 1 weeks"
ExpiresByType application/javascript "access plus 1 weeks"
ExpiresByType application/x-javascript "access plus 1 weeks"
ExpiresByType image/gif "access plus 1 months"
ExpiresByType image/jpeg "access plus 1 months"
ExpiresByType image/png "access plus 1 months"
ExpiresByType image/x-icon "access plus 1 months"

Achtung: Möglicherweise muss im Apache das Module mod_expire noch geladen werden!! Hier sollte die Anweisungen am besten von einer Anweisung umgeben sein, damit es nicht zu einem Fatal Error kommt.

Testen kann man das Ganze unter https://developers.google.com/speed/pagespeed/insights/ oder über Firebug im Browser!

Autor: Patrick Schwalger

... ist Gründer und Geschäftsführer bei der VCAT Consulting GmbH. Er betreut unsere Kunden aus den Bereichen Mittelstand und Öffentliche Hand in den Teams TYPO3 und Symfony.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Cookies bearbeiten