• Wenn du hier im Forum ein neues Thema erstellst, sind schon Punkte aufgeführt die du ausfüllen musst. Das dient im Allgemeinen dazu die notwendigen Informationen direkt mit der Frage bereitzustellen.
    Da in letzter Zeit immer wieder gerne das Formular gelöscht wurde und erst nach 3 Seiten Nachfragen die benötigten Infos für eine Hilfe kommen, werde ich nun jede Fragestellung die nicht einmal annähernd das Formular benutzt, sofort in den Sondermüll schicken.
    Füllt einfach die abgefragte Daten aus und alle können euch viel schneller helfen.

Leverage browser caching

-=TOM=-

Aktives Mitglied
Lizenzinhaber
Registriert
12. Okt. 2016
Beiträge
95
Punkte
33
XF Version
Provider/Hoster
AllInkl
Hallo Leute,

auf meiner Seite wird mir durch GTmetrix | Website Speed and Performance Optimization das Browser Caching bemängelt.

Caching.JPG

Was kann ich tun, um das in den Griff zu bekommen?
Kann man das über einen Eintrag in der .htaccess regeln?
Hättet Ihr vielleicht ein Beispiel, wie ich das eintragen muss, damit richtig gecached wird?
Darf von den Einträgen einer auf keinen Fall gecached werden?

Ich bedanke mich schon mal bei Euch!

Grüße, Tom
 
Das Logo und die Default Avatare kann man ohne Qualitätsverluste noch weiter komprimieren und dann natürlich cachen. JS auch und sogar noch bisl länger.

Auszug aus einer meiner .htaccess:

Code:
<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>

# Standard Expire Zeit 
<IfModule mod_deflate.c>
<FilesMatch "\.(js|jpg|jpeg|gif|png|css|txt|html)$">
ExpiresActive on
ExpiresDefault "access plus 1 month"
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>

# Kompression
<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>

# cachen spezifischer Dateitypen (day, week, month, year)
<IfModule mod_expires.c>
ExpiresActive Off
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/html "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType application/xhtml-xml "access plus 1 week"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
</IfModule>

# Expire Header (86.400 = 1 Tag, 604.800 = 1 Woche, 2.500.000 = über 1 Monat, 31.500.000 = über 1 Jahr)
<ifmodule mod_headers.c>
<filesmatch "\\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "max-age=2500000, public"
</filesmatch>
<filesmatch "\\.(css)$">
Header set Cache-Control "max-age=605000, public"
</filesmatch>
<filesmatch "\\.(js)$">
Header set Cache-Control "max-age=2500000, private"
</filesmatch>
<filesmatch "\\.(x?html?|php)$">
Header set Cache-Control "max-age=31500000, private, must-revalidate"
</filesmatch>
</ifmodule>

# Turn ETags Off
<ifmodule mod_headers.c>
Header unset ETag
Header unset Last-Modified
</ifmodule>
FileETag None

GTMetrix erläutert dir aber schon ganz gut was zu tun ist und mit etwas Google zu dem Theme findest auch reich Anleitungen die ins Detail gehen - auch auf Deutsch. :like
 
Danke!!
Ich habe auch Informationen dazu gefunden, aber hier noch nicht Bescheid gegeben.
Problem gelöst!
Und wie ? Wäre cool wenn du die Lösung preisgibst .

Noch was , da du ja auch bei all-incl. bist , was hast du in deiner config eingeben fürs cachen
 
Mein Cache-Bereich sieht so aus:

Code:
<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

<ifModule mod_expires.c>
     ExpiresActive On
     ############################################
     ## Add default Expires header
     ## http://developer.yahoo.com/performance/rules.html#expires
     <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
     ExpiresDefault "access plus 1 year"
     </FilesMatch>
     </ifModule>
 
Mein Cache-Bereich sieht so aus:

Code:
<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

<ifModule mod_expires.c>
     ExpiresActive On
     ############################################
     ## Add default Expires header
     ## http://developer.yahoo.com/performance/rules.html#expires
     <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
     ExpiresDefault "access plus 1 year"
     </FilesMatch>
     </ifModule>
Das teste ich nachher
 
Ich behaupte nicht ein Profi zu sein und behaupte daher nur: nein, unter Umständen nicht. Wenn sich die Grafiken dann ändern, ... obwohl, dann ändert sich deren Dateiname und der ETag ja auch und somit werden die neu gecached. :blush:
Ok - dazu müsste ich mich dann vielleicht auch erst noch mal schlauer machen. :D ;)

Vergiss bei aller Optimiererei für GTMetrix (nutze das auch und finds hilfreich) Google und Co aber nie die subjektive Nutzererfahrung auf deinem Forum. Ich empfinde z.B. perfekt optimierte Seiten, auf dem Desktop oftmals als störend Platzverschwenderisch für den gebotenen Inhalt. Klassisch sind die hippen One-Page Webseiten wo du dich nach unten zu tode scrollen kannst. Auf dem Smartfön perfekt - aber auf dem Desktop bescheiden. ;)

Was SEO und Nutzern zu gute kommt (mMn. die nicht stimmen muss ;) ):
- Datenverbrauch reduzieren = mehr Speed, weniger Traffic, und oft auch schnellere Reaktionszeiten
- Caching wo es nur geht und sinnvoll erscheint ;)
- Konzentration auf den echten Content und einzigartigen Kontent - denn deswegen kommen deine Nutzer ja ausgerechnet zu dir
- Saubere Konzepte für Desktop, Tablet und Smartfön - JANZ WICHTIG. :D
- Flache Strukturen im Seitenaufbau (interne Verlinkungen) - also auch hier, wenn möglich ist weniger mehr (hier hab ich selbst die größten Probleme)
- Sicherheit, soweit ich weiß hat da Google ja auch ein Auge drauf, deine Nutzer oft sowie so - und du solltest das größte Interesse dran haben.
 
Mein Cache-Bereich sieht so aus:

Code:
<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

<ifModule mod_expires.c>
     ExpiresActive On
     ############################################
     ## Add default Expires header
     ## http://developer.yahoo.com/performance/rules.html#expires
     <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
     ExpiresDefault "access plus 1 year"
     </FilesMatch>
     </ifModule>

wenn ich das nutze und aufs forum gehe kommt das An unexpected error occurred. Please try again later icl weisser seite
 
Ohjee, da bin ich ja jetzt auch nicht so der Fachmann.
Hast Du es vielleicht an die falsche Stelle in die .htaccess kopiert?
Macht Dir vielleicht ein / einen Befehl an einer falschen Stelle zu, obwohl er noch gebraucht wird.

Boar, klingt das bescheuert. Ich hoffe Du verstehst, was ich meine. :oops:
 
es geht :D vergesst die Meldung drüber .....
 
Ohjee, da bin ich ja jetzt auch nicht so der Fachmann.
Hast Du es vielleicht an die falsche Stelle in die .htaccess kopiert?
Macht Dir vielleicht ein / einen Befehl an einer falschen Stelle zu, obwohl er noch gebraucht wird.

Boar, klingt das bescheuert. Ich hoffe Du verstehst, was ich meine. :oops:

funktioniert einwandfrei nun :D
 
wie kann ich die beiden auch da rein bekommen ???
 

Anhänge

  • Bildschirmfoto 2017-01-21 um 17.29.42.png
    Bildschirmfoto 2017-01-21 um 17.29.42.png
    32,2 KB · Aufrufe: 5
Zurück
Oben