3

私は、cakephp2 ウェブサイトの速度改善の 1 つに取り組んでいます。

ここで、いくつかのヘッダーの有効期限とキャッシュを設定する必要があります。

しかし、htaccessにコードを配置する必要があるcakephpでは。

また、適切な htaccess コードを提案してください。

私が試してみました

#Expire Header
<FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf)$">
ExpiresDefault "access plus 2 hours"
</FilesMatch>

しかし、それは機能しません。また、他のコードをいくつか試しましたが、どれも機能していません.欠落しているキー設定はありますか?

もう1つ、パフォーマンスを向上させるための他のトリックがあれば、私に提案してください.

4

2 に答える 2

2

次のコードを .htaccess ファイルに追加します

# cache images/pdf docs for 10 days
<FilesMatch "\.(ico|pdf|jpg|jpeg|png|gif)$">
  Header set Cache-Control "max-age=864000, public, must-revalidate"
  Header unset Last-Modified
</FilesMatch>

# cache html/htm/xml/txt diles for 2 days
<FilesMatch "\.(html|htm|xml|txt|xsl)$">
  Header set Cache-Control "max-age=7200, must-revalidate"
</FilesMatch>

詳細http://tutorialpedia.org/tutorials/Apache+enable+file+caching+with+htaccess.html

于 2013-07-31T05:35:19.567 に答える