2016-09-13 5 views
1

私はかなり長い間ブラウザキャッシュを活用しようとしていましたが、何が問題なのかわかりません。私はそれを有効にするいくつかの方法を試しましたが、何も動作しません...レバレッジブラウザのキャッシュが機能しない - Htaccessとmod_expires Active

サイトはNamecheap Hostingで実行されています。

# 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

を:私はすでにこれはI'veが使用されたコードです...

をサポートに連絡し、mod_expiresをモジュールがアクティブであるかどうか尋ね、それがある顧客サポートに応じて

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

私はすでにいくつかのような他の方法を試してみました

誰もが私のコードで間違っている可能性がどのような考えを持っている場合、それは本当にいいだろう;)

+0

私は同じ問題に直面しています。私は 'htaccess'で何が変更されたかは問題です –

答えて

1

私はITに要するに を解決した: - は、私はこの問題を解決していますが有効にする必要がありますexpires_moduleモジュール。 Linuxの場合は、簡単にそれを行うことができます。ディープで

[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 

: - 彼らは自分に次のようなものを追加するためのワンストップの修正とのthatsだと思う何をして

人々は、他のものの間で、彼らは、ブラウザのキャッシュを活用する必要があると見ています.htaccessファイル:

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" 

これはすべてが順調と良いようだが、彼らはその後、再分析し、この問題はまだ普及していることがわかり、戻って自分のメトリクスツールに行く...彼らはその後、把握しようとしているときに、次を過ごしますなぜこれは動作していないと彼らのウェブサイトはまだdにOGハウスメトリクスが賢明です。まあ恐怖ではないという話は、ウェブサイトではなく、そのサーバーの問題です。 Debianサーバを使用している場合、これはあなたが探しているクイックフィックスです:あなたのDedicated/VPSにログインして、あなたのサーバにどのモジュールがロードされているかを確認する次のコマンドを発行して、expires_moduleを探しています。リスト

[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 

だから次回、このリストのexpires_moduleの兆候はありません、あなたがしなければならないすべてはに必ず、

[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 

ヘッド戻ってあなたの評価指標にそれをインストールし、テストを再実行しています上記のコードをhtaccessに追加してください。これで、レバレッジブラウザのキャッシングテストに合格しました。

私のウェブサイトの速度は85でしたが、私はレバレッジキャッシュを解決しようとしていましたが、最終的にはこれで解決しました。 Screenshot: - http://prntscr.com/fcuutv

関連する問題