2016-06-30 3 views
0

Ich habe gerade versucht, meine Website zu beschleunigen.Caching läuft ab Header-CSS und JS funktioniert nicht

Eines der Probleme, die auftreten, wenn ich einen Geschwindigkeitstest in Google mache, ist "Browser-Caching nutzen". Ich habe das nachgeschlagen und meinem htaccess Code hinzugefügt. Bitte siehe unten:

## EXPIRES CACHING ## 
 
<IfModule mod_expires.c> 
 
ExpiresActive On 
 
ExpiresByType image/jpg "access plus 1 year" 
 
ExpiresByType image/jpeg "access plus 1 year" 
 
ExpiresByType image/gif "access plus 1 year" 
 
ExpiresByType image/png "access plus 1 year" 
 
ExpiresByType text/css "access plus 1 month" 
 
ExpiresByType text/js "access plus 1 month" 
 
ExpiresByType application/pdf "access plus 1 month" 
 
ExpiresByType text/x-javascript "access plus 1 month" 
 
ExpiresByType application/x-shockwave-flash "access plus 1 month" 
 
ExpiresByType image/x-icon "access plus 1 year" 
 
ExpiresDefault "access plus 2 days" 
 
</IfModule> 
 
## EXPIRES CACHING ##

Dieses auf einige meiner Dateien gearbeitet hat, aber nicht alle von ihnen, und ich bin immer noch eine Nachricht, die Lasten meines js und CSS-Dateien nicht gesetzt sind immer abzulaufen . Könnte jemand helfen? Was mache ich falsch damit sie nicht ablaufen? Hier ist meine Fehlermeldung von Google auch mit dem vorherigen Code in der htaccess.

http://www.mydomain.co.uk/css/grid.css (expiration not specified) 
http://www.mydomain.co.uk/js/addons.js (expiration not specified) 
http://www.mydomain.co.uk/js/addons/jquery.cookiebar.js (expiration not specified) 
http://www.mydomain.co.uk/js/addons/jquery.flexslider.js (expiration not specified) 
http://www.mydomain.co.uk/js/base/html5shiv.js (expiration not specified) 
http://www.mydomain.co.uk/js/base/modernizr.custom.js (expiration not specified) 
http://www.mydomain.co.uk/js/nav.js (expiration not specified) 
http://www.mydomain.co.uk/mailer/css/form-style.css (expiration not specified) 
http://connect.facebook.net/en_US/sdk.js (20 minutes) 
http://www.google-analytics.com/analytics.js (2 hours) 
http://www.mydomain.co.uk/fonts/Effra_Std_Bd.woff (2 days) 
http://www.mydomain.co.uk/fonts/Effra_Std_Lt.woff (2 days) 
http://www.mydomain.co.uk/fonts/Effra_Std_Md.woff (2 days) 
http://www.mydomain.co.uk/fonts/Effra_Std_Rg.woff (2 days) 
http://www.mydomain.co.uk/mailer/js/jquery.validate.js (2 days) 
http://www.mydomain.co.uk/mailer/js/validate.js (2 days) 

Antwort

0

in Ihrem obigen Code der Suche gibt es ein paar fehlenden:

ExpiresByType text/javascript "access plus 1 month" 
ExpiresByType application/javascript "access plus 1 month" 
ExpiresByType application/x-javascript "access plus 1 month" 
ExpiresByType text/javascript "access plus 1 year" 
ExpiresByType application/x-ico "access plus 1 year" 
ExpiresByType image/icon "access plus 1 year" 

Das Facebook js-Datei ist nicht etwas, das Sie wie die anderen beheben können, da es sich um eine externe Datei ist ... Sie können eine cron verwenden, um dieses Problem zu beheben, das im Grunde die Datei speichert und lokal lädt. Sie finden Sie das gleiche Problem mit Dingen wie Google Analytics, Blei Forensics etc etc.

Wenn man sich mit einem cron versuchen wollen, dann bei dieser Führung einen Blick: http://diywpblog.com/leverage-browser-cache-optimize-google-analytics/

Obwohl ich es fühlen ist ziemlich sinnlos, besonders wenn es um Google Analytics geht ... sie werden dich nicht für ihre eigene Software bestrafen!