2016-09-13 1 views
1

Ich habe versucht, die Hebel-Cache-Cache für eine ganze Weile zu bekommen, und ich habe keine Ahnung, was das Problem sein könnte. Ich habe verschiedene Methoden ausprobiert, um es zu aktivieren, aber nichts funktioniert ...Nutzen Browser-Caching funktioniert nicht - Htaccess & mod_expires Active

Die Seite läuft auf Namecheap Hosting. Ich kontaktierte bereits die Unterstützung und fragte, ob das mod_expires Modul aktiv ist und entsprechend der Kundenbetreuung ist es ...

Dies ist der Code, Ive wurde mit:

# START --- Browser Cache Control 
 
# Turn on Expires and set default to 0 
 
ExpiresActive On 
 
ExpiresDefault A0 
 
    
 
# Set up caching on media files for 1 year (forever?) 
 
<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$"> 
 
ExpiresDefault A29030400 
 
Header append Cache-Control "public" 
 
</FilesMatch> 
 
    
 
# Set up caching on media files for 1 week 
 
<FilesMatch "\.(gif|jpg|jpeg|png|swf)$"> 
 
ExpiresDefault A604800 
 
Header append Cache-Control "public" 
 
</FilesMatch> 
 
    
 
# Set up 2 Hour caching on commonly updated files 
 
<FilesMatch "\.(xml|txt|html|js|css)$"> 
 
ExpiresDefault A7200 
 
Header append Cache-Control "proxy-revalidate" 
 
</FilesMatch> 
 
    
 
# Force no caching for dynamic files 
 
<FilesMatch "\.(php|cgi|pl|htm)$"> 
 
ExpiresActive Off 
 
Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform" 
 
Header set Pragma "no-cache" 
 
</FilesMatch> 
 
# END --- Browser Cache Control

ich habe bereits versucht, einige andere Methoden wie:

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

Es ist wirklich schön wäre, wenn jemand eine Idee hat, was mit meinem Code falsch sein könnte;)

+0

Ich bin mit dem gleichen Problem konfrontiert. Egal, was ich in 'htaccess' geändert habe, es funktioniert nicht –

Antwort

1

ICH HABE BESCHLOSSEN IT Kurz: - ich dieses Problem nur gelöst, aber Sie haben zu ermöglichen expires_module-Modul. Für Linux kann man es einfach so machen.

[email protected]: sudo a2enmod expires 
Enabling module expires. 
To activate the new configuration, you need to run: 
service apache2 restart 
[email protected]: sudo service apache2 restart 
[....] Restarting web server: 
. ok 

In Deep -

Menschen sehen, dass unter anderem die sie benötigen, um Browser-Caching zu nutzen, so dass sie tun, was sie denken, ist die One-Stop fix und das ist so etwas wie das zu folgenden hinzufügen, um ihre .htaccess-Datei:

ExpiresActive On 
ExpiresDefault "access plus 5 seconds" 
ExpiresByType image/x-icon "access plus 2592000 seconds" 
ExpiresByType image/jpeg "access plus 2592000 seconds" 
ExpiresByType image/png "access plus 2592000 seconds" 
ExpiresByType image/gif "access plus 2592000 seconds" 
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds" 
ExpiresByType text/css "access plus 604800 seconds" 
ExpiresByType text/javascript "access plus 216000 seconds" 
ExpiresByType application/javascript "access plus 216000 seconds" 
ExpiresByType application/x-javascript "access plus 216000 seconds" 
ExpiresByType text/html "access plus 600 seconds" 
ExpiresByType application/xhtml+xml "access plus 600 seconds" 

das scheint alles gut und gut, aber sie dann wieder in ihrem Metriken Werkzeug zurück, neu zu analysieren und sehen, dass dieses Problem immer noch weit verbreitet ist .. sie dann die nächste verbringen, während versuchen, herauszufinden, warum das nicht funktioniert und ihre website immer noch in d ist og Haus-Metriken weise. naja angst nicht das problem ist nicht eine website die man sozusagen spricht, es ist ein server. Wenn Sie einen Debian - Server verwenden, ist dies die schnelle Lösung, nach der Sie gesucht haben: Melden Sie sich bei Ihrem Dedicated/VPS an und geben Sie den folgenden Befehl aus, um zu sehen, welche Module auf Ihrem Server geladen sind: Sie suchen nach dem expires_module in der

Liste
[email protected]: sudo apachectl -M 
Loaded Modules: 
core_module (static) 
log_config_module (static) 
logio_module (static) 
version_module (static) 
mpm_prefork_module (static) 
http_module (static) 
so_module (static) 
alias_module (shared) 
auth_basic_module (shared) 
authn_file_module (shared) 
authz_default_module (shared) 
authz_groupfile_module (shared) 
authz_host_module (shared) 
authz_user_module (shared) 
autoindex_module (shared) 
cgi_module (shared) 
deflate_module (shared) 
dir_module (shared) 
env_module (shared) 
mime_module (shared) 
negotiation_module (shared) 
php5_module (shared) 
reqtimeout_module (shared) 
rewrite_module (shared) 
setenvif_module (shared) 
ssl_module (shared) 
status_module (shared) 
Syntax OK 

So ist es kein Zeichen der expires_module in dieser Liste, next up alles, was Sie tun müssen, ist es zu installieren

[email protected]: sudo a2enmod expires 
Enabling module expires. 
To activate the new configuration, you need to run: 
service apache2 restart 
[email protected]: sudo service apache2 restart 
[....] Restarting web server: 
. ok 

Kopf zurück zu Ihrer Metriken und den Test erneut ausführen, achten Sie darauf, füge den oben angegebenen Code deinem htaccess hinzu. Sie sollten nun den Leverage-Browser-Caching-Test bestanden haben.

Meine Website Geschwindigkeit war 85, ich versuchte Leverage Cache aufzulösen, aber schließlich habe ich damit gelöst. Screenshot: - http://prntscr.com/fcuutv