>>  Site Map >>  Forums >>  Admin_HostingDomain

Forum module - topics in forum:



Admin_HostingDomain - Các hướng dẫn cài đặt quản lý và mua bán hosting domain, Cấu hình server web



.htaccess làm tăng tốc trang web của bạn với Caching [ hay ]

phương pháp sau sẽ làm giảm đỉ số lượng Bandwidth phải sử dụng với web của bạn và tăng tốc đọ truy cập web của nguòi dùng

bài viết được biên soạn bởi thành viên *http://www.xaluan.com
ghi rõ nguồn nếu copy tù đây nhé..

các bạn đều biết phần lớn các file images, css, javascript, files loại khác đèu có thể làm cho chặt chẽ cáu hình và sủ dụng để tăng tóc download với nguòi sủ dụng. hơn nữa nó có thể báo cho trình duyệt của người dùng luu trữ lại cho dùng lần sau bằng cách thông báo thời gian sủa lại hoạc câp nhật đẻ không tốn thời gian và luu lượng trao đổi khi ghé thăm web..

sau đây là mã số của thời gian báo cho trình duyệt bạn có thể sủ dụng

Quote: :

#=============================================================================#
# TIME CHEAT SHEET
#=============================================================================#
# 300 5 M # 604800 1 W
# 2700 45 M # 1814400 3 W
# 3600 1 H # 2419200 1 M
# 54000 15 H # 14515200 6 M
# 86400 1 D # 26611200 11 M
# 518400 6 D # 29030400 1 Y (never expire)


còn đây là hai giải pháp cho việc này
sử dụng Apache Module mod_expires
ví dụ

Code: :

ExpiresActive On
ExpiresDefault A300
ExpiresByType image/x-icon A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType text/css A2592000
ExpiresByType image/gif A604800
ExpiresByType image/png A604800
ExpiresByType image/jpeg A604800
ExpiresByType text/plain A604800
ExpiresByType application/x-shockwave-flash A604800
ExpiresByType video/x-flv A604800
ExpiresByType application/pdf A604800
ExpiresByType text/html A300


cách hai sử dụng mod_headers thêm vào header của các html -- cách này khá dễ và ưa chuộng
ví dụ
Code: :

# htm files are php
AddHandler application/x-httpd-php .php .htm

# setup errordocuments to local php file
ErrorDocument 404 /cgi-bin/error.htm
ErrorDocument 403 /cgi-bin/error.htm
ErrorDocument 500 /cgi-bin/error.htm

# Turn on Expires and set default to 0
ExpiresActive On
ExpiresDefault A0

# Set up caching on media files for 1 year (forever?)
<FilesMatch "\.(ico|flv|pdf|mov|mp3|wmv|ppt)$">
  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, proxy-revalidate"
</FilesMatch>

# Set up 2 Hour caching on commonly updated files
<FilesMatch "\.(xml|txt|html|js|css)$">
  ExpiresDefault A7200
  Header append Cache-Control "private, proxy-revalidate, must-revalidate"
</FilesMatch>

# Force no caching for dynamic files
<FilesMatch "\.(php|cgi|pl|htm)$">
  ExpiresDefault A0
  Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform"
  Header set Pragma "no-cache"
</FilesMatch>

nguồn *http://www.xaluan.com do vipdanchoi post




Search from ALEXA


put your ads here