您好,欢迎访问三七文档
AngusLi(@angusli)PerformanceparadigmBasicrulesofwebsiteperformanceOptimizeLAMPstackTweakMagentoboxTools&utilitiesDonaldKnuthsays“Prematureoptimizationistherootofallevil”...sochoosetherighttimetostartyouroptimizationPerformanceoptimizationisanevergoingtask…sodon’tthinkyouroptimizationis“onceforall”,keepidentifyingthebottleneckofyoursiteandmakeimprovementlittlebylittleProcessyourpageasquicklyaspossibleTransferyourcontentasquicklyaspossibleRenderyourpageasquicklyaspossibleServersideNetwork/HTTPBrowserPerformanceoptimization#1:MakeFewerHTTPRequests#2:UseaContentDeliveryNetwork#3:AddanExpiresHeader#4:GzipComponents#5:PutStylesheetsattheTop#6:PutScriptsattheBottom#7:AvoidCSSExpressions#8:MakeJavaScriptandCSSExternal#9:ReduceDNSLookups#10:MinifyJavaScript#11:AvoidRedirects#12:RemoveDuplicateScripts#13:ConfigureEtags#14:MakeAJAXCacheable----HighPerformanceWebSitesbySteveSoudersInstallaminimalLinuxdistributionwithnecessarypackagesonly,getridofGUI,X-windowetc.Stopanddisabletheunusedservices,e.g.cupsTweakkernelparameters:#echo'8192'/proc/sys/fs/file-max#echo'32768'/proc/sys/fs/inode-max#echo268435456/proc/sys/kernel/shmall#echo268435456/proc/sys/kernel/shmmax#ulimit-n4096CompilerequiredmodulesstaticallyinsteadofDSO(DynamicSharedObject),anddisableduselessmodules./configure--prefix=/usr/local/apache2--disable-status--disable-userdir--disable-threads--disable-ipv6--enable-modules='sslsorewritedeflateheadersexpires'Why?“DSOhasthefollowingdisadvantages”Open.htaccessunderMagentorootdirectory,uncommentthedirectivesbetween“IfModulemod_deflate.c”and“/IfModuleIfModulemod_deflate.cAddOutputFilterByTypeDEFLATEtext/htmltext/plaintext/xmltext/csstext/javascriptBrowserMatch^Mozilla/4gzip-only-text/htmlBrowserMatch^Mozilla/4\.0[678]no-gzipBrowserMatch\bMSIE!no-gzip!gzip-only-text/htmlSetEnvIfNoCaseRequest_URI\.(?:gif|jpe?g|png)$no-gzipdont-varyHeaderappendVaryUser-Agentenv=!dont-vary/IfModuleOpen.htaccessandusefollowinglinestoreplacethesectionbetween“IfModulemod_expires.c”and“/IfModule”IfModulemod_expires.cExpiresActiveOnExpiresDefaultaccessplus1monthExpiresByTypeimage/x-iconaccessplus1monthExpiresByTypetext/htmlaccessplus1monthExpiresByTypetext/plainaccessplus1monthExpiresByTypetext/cssaccessplus1monthExpiresByTypeapplication/x-javascriptaccessplus1monthExpiresByTypeapplication/x-shockwave-flashaccessplus1month/IfModuleOpen.httaccessandscrolltotheend,uncommentthedirective“FileETagnone”,alsoaddseverallinesmoreifyouhaven’tenabledKeepAliveinhttpd.confFileETagNoneKeepAliveOnMaxKeepAliveRequests200KeepAliveTimeout5Openyourmy.cnfandupdatethefollowingparameters:skip-name-resolveinnodb_buffer_pool_size=768Minnodb_flush_log_at_trx_commit=2Astimegoesby,useTuningPrimertocheckyourMySQLstatusandadjustconfigurationaccordinglySimilarascompilingApache,compilerequiredextensionsstaticallyanddisableunusedmodules./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache2/bin/apxs--with-config-file-path=/etc/php--with-png-dir--with-jpeg-dir--with-gd--with-curl--with-zlib--enable-mbstring--with-mcrypt--with-freetype-dir=/usr--with-mysql=/usr/bin/mysql--with-mysqli--enable-pdo--with-pdo-mysql=/usr/bin/mysql--without-pdo-sqlite--with-opensslDownloadlateststableversionfromeaccelerator.netCompilebyenablingSharedMemory(forMagentocache,willtalkaboutthislater)./configure--with-eaccelerator-shared-memory--enable-eaccelerator=shared--with-php-config=/usr/local/php/bin/php-configAddanExpiresHeaderGzipComponentsConfigureEtagsAlightweightLAMPstackwhichcanboostyourwebsiteperformancemaximallyAfast-enoughenvironmenttorunMagentoefficientlyLet’smovetoMagentobox!CachewithmultipleadaptorsCompilerCombineCSS&JSfilesParallelDownloadsGotoMagentoAdminPanelSystemCacheManagementAllCacheEnableLayeredNavigationYesAdminPanelSystemConfigurationCatalogFrontendUseFlatCatalogCategoryYesUseFlatCatalogProductYesOpen{Magento_root}/app/etc/local.xml,addthefollowingthreelines.../resourcessession_save![CDATA[files]]/session_savecachebackendeaccelerator/backend/cache/global...AdminPanelSystemToolsCompilationRunCompilationProcessAdminPanelSystemConfigurationDeveloperJavascriptSettingsMergeJavascriptFilesYesCSSSettingsMergeCSSFilesYesSetupthefollowingseparatedomainsandpointtheVirtualHostDocumentRoottocorrespondingpathsunderMagentofolderjs.foo.com{Magento_root}/jsmedia.foo.com{Magento_root}/mediaskin.foo.com{Magento_root}/skinThengotoAdminPanelSystemConfigurationWebsiteUnsecure,andconfiguretheBasicURLsaccordinglyMakeFewerHTTPRequestsPutStylesheetsattheTopMakeJavaScriptandCSSExternalReduceDNSLookupsMinifyJavaScriptMakeFewerHTTPRequestsAddanExpiresHeaderGzipComponentsPutStylesheetsattheTopAvoidCSSExpressions(appliesbydefault)MakeJavaScriptandCSSExternalReduceDNSLookupsMinifyJavaScriptAvoidRedirects(appliesbydefault)RemoveDuplicateScripts(appliesbydefault)ConfigureEtagsMakeAJAXCacheable(appliesbydefault)
本文标题:Magento性能优化指南(Magento Performance Optimization 101
链接地址:https://www.777doc.com/doc-5837536 .html