How to reduce TTFB (Time to First byte) of my mage

2020-08-01 07:22发布

问题:

Please help me reduce TTFB of my website (magento) which is running on VPS Dedicated Hosting with CentOS release 6.6 (Final).

Current Time To First Byte is: 19.427 seconds

回答1:

Just caches don't improve performance, they reduce hardware utilization for repeated requests.

While implementing the Will Farrell's other suggestions, you need to identify those parts of Magento code that are slow. For that, you will need to enable Magento Profiler – the built in Magento tool that lets you see what Magento is doing and on what it spends most of the page load time.

here is the details method how to enable and use Magento profiler:

http://tutorialmagento.com/how-to-reduce-time-to-first-byte-ttfb-and-speed-up-magento



回答2:

The main changes to be made are:

  1. Gzipping Components (compression)
  2. Optimizing Images
  3. Using a content delivery network (CDN)
  4. Minifying your JavaScript and CSS
  5. Minimize the amount of HTTP requests

Before: 3.5 to 5.5 seconds (depending on time of day)

After: 1.5 to 2.5 seconds (depending on time of day)

Reference



回答3:

Few things to get you started:

  • Enable Full Page Cache in Magento
  • Upgrade PHP: 5.7 is way should be able to cut the TTFB in half, if you're stuck using a lower version try adding HHVM. Checkout http://zsuraski.blogspot.ca/ for some benchmarks.
  • Add DB cache: memcached, redis for sessions, they're a life saver.
  • Remove DB logging. Magento loves to hit the DB
  • Use nginx to server you pages over apache
  • HTTP/2: As a bonus add in SPDY (soon to be replaced with HTTP/2, so keep an eye out)
  • Varnish server can be added between nginx and your php layer.

There are many more micro optimizations. A good goal is to have the page, above the fold, render in <100ms.