Skip to content
jagaweb.Book the Review
Performance

Optimizing Time to First Byte (TTFB) on Malaysian Servers

4 min readBy JagaWeb Technical Team

Deep dive into server-level TTFB optimization using PHP OPcache, Redis Object Caching, and FastCGI Microcaching on Nginx.

Beyond Plugins: Server-Level TTFB Optimization

If your Time To First Byte (TTFB) is over 600ms, your visitors are feeling the lag. Installing a caching plugin is surface-level. Real TTFB optimization happens at the server layer.

1. Enable and Tune PHP OPcache

PHP is an interpreted language. Every time a script runs, it must be compiled into bytecode. OPcache stores this precompiled bytecode in memory, skipping the compilation phase.

Edit your php.ini:

opcache.enable=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=10000
opcache.revalidate_freq=60
opcache.fast_shutdown=1

Restart PHP-FPM. This alone can cut PHP execution time by 50%.

2. Redis Object Caching

WordPress runs hundreds of identical database queries on every page load (e.g., fetching wp_options). Redis caches these SQL query results in RAM.

  1. Install Redis on your VPS: apt install redis-server
  2. Install the PHP Redis extension: apt install php-redis
  3. Use a persistent object cache drop-in (like the Redis Object Cache plugin) to force WordPress to use Redis instead of MySQL for transient data.

3. Nginx FastCGI Microcaching

If you are running Nginx, you can cache dynamic PHP pages directly in Nginx memory, bypassing PHP entirely for anonymous visitors.

In your Nginx http block:

fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";

In your PHP location block:

fastcgi_cache WORDPRESS;
fastcgi_cache_valid 200 60m;
fastcgi_cache_bypass $no_cache;
fastcgi_no_cache $no_cache;

(You will need specific rules to set $no_cache to 1 for logged-in users and WooCommerce carts).


Is slow TTFB tanking your Google rankings and conversion rates? We engineered the server architecture for Agros Empire to achieve consistent ~150ms TTFB natively, without relying on fragile caching plugins.

Get a professional architectural audit with JagaWeb's RM5,000 Ownership & Access Review, or let us implement and maintain these optimizations for you via our RM450/month Care Plan.

PROTECT YOUR ASSETS

Ready to verify who owns your website?

Replace uncertainty with a decision-ready ownership and access report. The fixed Ownership & Access Review is RM1,500 before SST and includes a 30-day action plan.

WhatsApp