Thứ Tư, 7 tháng 8, 2013

Leverage browser caching - Expires


Ngày 07 tháng 08 năm 2013
Khi làm việc với đối tác Switzeland gặp gấn đề  Leverage browser caching
link kiểm tra từ google http://developers.google.com/speed/pagespeed/insights/?url=mydomain.com
Khi nanazy view  Leverage browser caching

Mô tả: cache lưu trữ ở Browser có hạn sử dụng gọi là Expire
Các file sẽ lưu trữ ở Cach Browser có nội dung thuộc loại STATIC (CSS, javascript, media, image, pdf .....)
Yêu cầu của đối tác: các loại này đều phải có thời gian hết hạn EXPIRE.

Cách thực hiện:
Mở file .htaccess (hoặc htaccess.txt) thêm đoạn sau :
Sau khi thêm kiểm tra lại từ link developer google để xem kết quả

# 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 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"

# CSS
ExpiresByType text/css "access 1 month”

# Javascript
ExpiresByType application/javascript "access plus 1 year"

0 nhận xét:

Đăng nhận xét