Tôi đã nhập thông tin sau vào tệp ".htacces" của mình để bắt đầu lưu vào bộ nhớ cache Nội dung web. Theo Google Page Speed và Yslow, các trang vẫn chưa được lưu trong bộ nhớ cache. Các mô-đun có sai không? Hay là các ứng dụng không hiển thị chính xác dữ liệu?htaccess caching không hoạt động
trang web đang chạy trên Apache 2.0 trên Server
.htaccess (phần với các module bộ nhớ đệm):
# Expire headers
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 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"
</ifModule>
# Cache-Control Headers
<ifModule mod_headers.c>
#month
<filesMatch "\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
#week
<filesMatch "\.(css|js)$">
Header set Cache-Control "max-age=604800, public"
</filesMatch>
#day
<filesMatch "\.(x?html?|php)$">
Header set Cache-Control "max-age=43200, private, must-revalidate"
</filesMatch>
</ifModule>
# END Cache-Control Headers
# Turn ETags Off
<ifModule mod_headers.c>
Header unset ETag
</ifModule>
FileETag None
# Remove Last-Modified Header
<ifModule mod_headers.c>
Header unset Last-Modified
</ifModule>
Kiểm tra các tiêu đề hết hạn đã gửi. Sử dụng công cụ nhà phát triển Chrome hoặc tab net trong firebug. Có thể là htaccess là vô hiệu hóa, hoặc mod_expires đó không được kích hoạt. – Gerben