Hallo,
ich bin gerade dabei meine Website zu optmieren. Aktuell 93 / 100 Punkte bei Google PageSpeed Insights. Jetzt verzweifel ich aber beim Caching der einzigen .js Datei.
Optimierungsvorschläge Google PageSpeed Insights:
Browser-Caching nutzen
Das Festlegen eines Ablaufdatums oder eines Höchstalters in den HTTP-Headern für statische Ressourcen weist den Browser an, zuvor heruntergeladene Ressourcen über die lokale Festplatte anstatt über das Netzwerk zu laden.
Nutzen Sie Browser-Caching für die folgenden cachefähigen Ressourcen:
- https://--.--/min.js (2,5 Tage)
Infos zur betroffenen .js Datei (entnommen von gtmetrix.com):
[TABLE='class: MsoNormalTable']
cache-control
[/td][td][FONT=&]max-age=216000, private[/FONT]
[/td][/tr][tr][td]last-modified
[/td][td][FONT=&]Sun, 22 Jul 2018 16:56:17 GMT[/FONT]
[/td][/tr][tr][td]status
[/td][td][FONT=&]200[/FONT]
[/td][/tr][tr][td]accept-language
[/td][td][FONT=&]none[/FONT]
[/td][/tr][tr][td]date
[/td][td][FONT=&]Sun, 22 Jul 2018 16:56:17 GMT[/FONT]
[/td][/tr][tr][td]vary
[/td][td][FONT=&]Accept-Encoding[/FONT]
[/td][/tr][tr][td]content-encoding
[/td][td][FONT=&]gzip[/FONT]
[/td][/tr][tr][td]strict-transport-security
[/td][td][FONT=&]max-age=31536000[/FONT]
[/td][/tr][tr][td]content-type
[/td][td][FONT=&]application/javascript; charset=utf-8[/FONT]
[/td][/tr][tr][td]server
[/td][td][FONT=&]Apache[/FONT]
[/td][/tr][tr][td]expires
[/td][td][FONT=&]Tue, 21 Aug 2018 16:56:17 GMT[/FONT]
[/td][/tr][tr]
[TD='colspan: 2'] Request Headers[/TD]
user-agent
[/td][td][FONT=&]Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537[/FONT]
[FONT=&].36[/FONT]
accept
[/td][td][FONT=&]*/*[/FONT]
[/td][/tr][tr][td]:method
[/td][td][FONT=&]GET[/FONT]
[/td][/tr][tr][td]accept-language
[/td][td][FONT=&]en-US,en;q=0.9[/FONT]
[/td][/tr][tr][td]accept-encoding
[/td][td][FONT=&]gzip, deflate, br[/FONT]
[/td][/tr][tr][td]:authority
[/td][td]--
[/td][/tr][tr][td]:scheme
[/td][td][FONT=&]https[/FONT]
[/td][/tr][tr][td]:path
[/td][td][FONT=&]/min.js[/FONT]
[/td][/tr][tr][td]referer
[/td][td]--
[/td][/tr]
[/TABLE]
Meine .htaccess:
# 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>
## EXPIRES CACHING ##<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType application/vnd.ms-fontobject "access 1 year"
ExpiresByType application/x-font-ttf "access 1 year"
ExpiresByType application/x-font-opentype "access 1 year"
ExpiresByType application/x-font-woff "access 1 year"
ExpiresByType image/svg+xml "access 1 year"
ExpiresByType text/html "access 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType image/gif "access 2 months"
ExpiresByType image/png "access 2 months"
ExpiresByType image/jpg "access 2 months"
ExpiresByType image/jpeg "access 2 months"
ExpiresByType image/gif "access 2 months"
ExpiresByType application/pdf "access 1 year"
ExpiresByType application/x-shockwave-flash "access 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##
<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>
# Deflate Compression by MimeType
<IfModule mod_deflate.c>
<FilesMatch "\.(js|jpg|jpeg|gif|png|css|svg)$">
ExpiresActive on
ExpiresDefault "access plus 1 month"
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule (.*) https://%%7bhttp_host%7d/%241 [R=301,L]
ErrorDocument 404 /404.html
Header set Strict-Transport-Security "max-age=31536000"
AddDefaultCharset UTF-8
AddCharset UTF-8 .htm .html .css .js .woff
# Fonts
# Add correct content-type for fonts
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
AddType image/svg+xml .svg
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule (.*) https://%%7bhttp_host%7d/%241 [R=301,L]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.--\.--$ [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://--.--/$1 [L,R=301]
Meine Website habe ich mit -- gekürzt.
Kann mir hier bitte jemand helfen? Ich komme seit Ewigkeiten nicht zum gewünschten Effekt und ich kenne mich auch nicht sooo gut aus... Vielen Dank!