2022-09-27 10:03:33 - 米境通跨境电商
前面优化
mod_deflate模块,将text、css和javascript先进行压缩再发送到浏览器。这样就会减少网络下载量,缩短等待时间,示例如下:
#Insertfilteronallcontent
SetOutputFilterDEFLATE
#Insertfilteronselectedcontenttypesonly
AddOutputFilterByTypeDEFLATEtext/htmltext/plaintext/xmltext/csstext/javascriptapplication/javascript
#Netscape4.xhassomeproblems...
BrowserMatch^Mozilla/4gzip-only-text/html
#Netscape4.06-4.08havesomemoreproblems
BrowserMatch^Mozilla/4.0[678]no-gzip
#MSIEmasqueradesasNetscape,butitisfine
BrowserMatchMSIE!no-gzip!gzip-only-text/html
#Don'tcompressimages
SetEnvIfNoCaseRequest_URI.(?:gif|jpe?g|png)$no-gzipdont-vary
#Makesureproxiesdon'tdeliverthewrongcontent
HeaderappendVaryUser-Agentenv=!dont-vary
#enableresultinghtmlcompression
php_flagzlib.output_compressionon
启用ExpiresHeaders
注意:这一配置在Litespeedservers无效
浏览器使用ExpiresHeaders来确定页面组件可以被缓存多长时间。静态的部件,如图像,可以设置为永不过期,但还是建议设置一个ExpiresHeaders。要打开这个特性,可以取消注释对应的行并添加"ExpiresActiveOn"如下所示:
ExpiresActiveOn
ExpiresDefault"accessplus1year"
禁用ETags
ETags(Entitytags)是服务器和浏览器的一个功能,它用来判断浏览器缓存里的元素是否和原来服务器上的一致。ETags比last-modifieddate更具有弹性,它用一个独一无二的字符串来标识一个元素的版本。要关闭它很简单,做法如下:
FileETagnone
日志太大,执行如下sql:
truncatedataflow_batch_export;
truncatedataflow_batch_import;
truncatelog_customer;
truncatelog_quote;
truncatelog_summary;
truncatelog_summary_type;
truncatelog_url;
truncatelog_url_info;
truncatelog_visitor;
truncatelog_visitor_info;
truncatelog_visitor_online;
truncatereport_viewed_product_index;
truncatereport_compared_product_index;
truncatereport_event;
setforeign_key_checks=0;
truncateindex_process_event;
truncateindex_event;
setforeign_key_checks=1;
mysql配置优化,充分发挥你的硬件资源,下面的数值要根据你的配置调整
key_buffer_size=512M
max_allowed_packet=64M
table_cache=512
sort_buffer_size=4M
net_buffer_length=8K
read_buffer_size=4M
read_rnd_buffer_size=2M
myisam_sort_buffer_size=64M
tmp_table_size=128M
query_cache_size=96M
query_cache_type=1
thread_cache_size=8
max_connections=400
wait_timeout=300
5、将magento的var目录挂载到内存中,加快读取速度,如
mount-ttmpfs-osize=100M,mode=0777tmpfsvar
6、安装php加速器,如APC,XCACHE,eAccelerator,安装方法参考相关的网站
然而归于根本,最大的优化来自于对模板,对代码,对block的优化。
在Magento的优化中,Mysql的优化是很重要的,在Magento的官方网给出了有关Mysql的优化,官方网并没有要我们把Mysql的存储引擎改为innodb,但我觉的得这是很有必要的,当改成innodb后,还得把Mysql的配置文件修改修改下,有时根据官方的文档来并不能成功,这时就要看你的环境而定了。