2017-11-21 44 views
5

Các tập tin htaccess trông như thế này:Enable mod_expires cho trình duyệt của bộ nhớ đệm

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 




</IfModule> 
<IfModule mod_expires.c> 


# Enable expirations 
ExpiresActive On 
# Default directive 
ExpiresDefault "access plus 1 month" 

# My favicon 
ExpiresByType image/x-icon "access plus 1 year" 
# Images 
ExpiresByType image/gif "access plus 1 week" 
ExpiresByType image/png "access plus 1 week" 
ExpiresByType image/jpg "access plus 1 week" 
ExpiresByType image/jpeg "access plus 1 week" 
# CSS 
ExpiresByType text/css "access plus 1 week" 
# Javascript 
ExpiresByType application/javascript "access plus 1 week" 
ExpiresByType text/html "access plus 1 day" 
</IfModule> 

# END WordPress 

Bất kỳ lý do tại sao điều này sẽ không cho phép bộ nhớ đệm trình duyệt? Tôi đang chạy Centos 5 và đã chắc chắn rằng module hết hạn được cài đặt.

+0

Bạn có thử tải nó bằng cách 'sudo a2enmod hết hạn' và sau đó kiểm tra xem nó đã nạp' apachectl -M' chưa. –

+0

Cảm ơn bạn đã bình luận nhưng Centos không sử dụng a2enmod. – Atrag

Trả lời

0

Cố gắng sử dụng này ... bằng cách mở rộng tập tin ... thay đổi max-age cho nhu cầu của bạn

và thậm chí sử dụng Deflate để nén kích thước tải

# 1 YEAR = 29030400 || 2 DAYS = 172800 || 1 MIN = 60 
# 1 WEEK = 604800 
<filesMatch "\.(jpg|jpeg|png|gif|swf|xml|txt|css|js|ico|pdf|flv|html|htm)$"> 
Header set Cache-Control "max-age=604800, public" 
</filesMatch> 

#compress 
<filesMatch "\.(js|css|json|html|xml)$"> 
SetOutputFilter DEFLATE 
</filesMatch> 
Các vấn đề liên quan