Skip to content
  • Quick Ref
  • Contact
  • About
wpcanyon.com

wpcanyon.com

Tag: TTFB

Reduce TTFB on budget hosting (OPcache + object cache)

Posted on August 19, 2025 By Admin No Comments on Reduce TTFB on budget hosting (OPcache + object cache)

Reduce TTFB on Budget Hosting (OPcache + Object Cache)

Time To First Byte (TTFB) is a critical performance metric that measures how long it takes for a user’s browser to receive the first byte of data from your server. On budget WordPress hosting, TTFB can often be slow due to limited server resources. This tutorial shows you how to reduce TTFB effectively by enabling OPcache and an object cache, improving your site’s responsiveness without upgrading your hosting plan.

Quick Fix: Enable OPcache and Object Cache

  1. Verify your hosting supports PHP OPcache and enable it in your PHP configuration.
  2. Install and configure a persistent object cache like Redis or Memcached.
  3. Integrate the object cache with WordPress using a suitable plugin.
  4. Test your site’s TTFB before and after to confirm improvements.

Why This Happens

Budget hosting environments typically share resources among many users, leading to slower PHP execution and database queries. WordPress dynamically generates pages by running PHP scripts and querying the database on each request, which increases TTFB.

OPcache caches compiled PHP bytecode, so PHP scripts don’t need to be recompiled on every request, reducing CPU load and execution time.

Object caching stores database query results and other expensive computations in memory, allowing WordPress to serve data faster without repeated database hits.

Combining OPcache with a persistent object cache significantly reduces backend processing time, lowering TTFB even on limited hosting.

Requirements

  • Budget WordPress hosting with PHP 7.4 or higher (PHP 8.x preferred).
  • Access to PHP configuration (php.ini or hosting control panel).
  • Redis or Memcached service available on your server or via your hosting provider.
  • Ability to install WordPress plugins.

Step-by-step Guide

1. Enable OPcache in PHP

Check if OPcache is enabled by creating a phpinfo.php file in your WordPress root directory:

<?php
phpinfo();
?>

Access it via your browser (e.g., https://yourdomain.com/phpinfo.php) and look for the Zend OPcache section.

If OPcache is disabled, enable it by editing your php.ini file or using your hosting control panel’s PHP settings. Add or update these lines:

opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.revalidate_freq=2
opcache.validate_timestamps=1

Restart your web server or PHP-FPM process if you have control over it.

2. Install Redis or Memcached

Check if your hosting provider supports Redis or Memcached. If yes, enable the service via your control panel or request support.

If you have SSH access and permission, install Redis (example for Ubuntu):

sudo apt update
sudo apt install redis-server
sudo systemctl enable redis-server
sudo systemctl start redis-server

For Memcached:

sudo apt update
sudo apt install memcached
sudo systemctl enable memcached
sudo systemctl start memcached

3. Install and Configure Object Cache Plugin in WordPress

Use a plugin to connect WordPress with Redis or Memcached. Popular options:

  • Redis Object Cache (for Redis)
  • Memcached Redux (for Memcached)

Example: Installing Redis Object Cache

  1. Go to Plugins > Add New in your WordPress dashboard.
  2. Search for Redis Object Cache and install it.
  3. Activate the plugin.
  4. Go to Settings > Redis and click Enable Object Cache.

4. Verify Object Cache is Working

Use the plugin’s status page or install the Query Monitor plugin to check if object caching is active and reducing database queries.

5. Test TTFB Improvement

Use tools like GTmetrix, Pingdom, or WebPageTest to measure TTFB before and after enabling caching.

Common Pitfalls

  • OPcache not enabled: Some shared hosts disable OPcache by default. Confirm with your provider.
  • Redis/Memcached not available: Budget hosts may not support these services or restrict access.
  • Plugin conflicts: Object cache plugins can conflict with other caching or optimization plugins.
  • Incorrect configuration: Ensure Redis/Memcached connection details match your server setup.
  • Not clearing cache after changes: Always flush caches after plugin or theme updates.

Works on

Server Control Panel Cache Support
Apache, Nginx, LiteSpeed cPanel, Plesk, DirectAdmin PHP OPcache, Redis, Memcached

FAQ

Q: Can I enable OPcache on any shared hosting?
A: Not always. Many budget hosts enable OPcache by default, but some restrict access. Check with your hosting provider.
Q: Is Redis or Memcached better for object caching?
A: Both are effective. Redis offers more features and persistence, while Memcached is simpler. Use whichever your host supports.
Q: Will enabling these caches reduce my database size?
A: No, caching reduces query load and speeds up response times but does not affect database size.
Q: How often should I clear OPcache and object
…
Speed & Security

Reduce TTFB on cheap hosting (object cache & OPcache)

Posted on August 19, 2025 By Admin No Comments on Reduce TTFB on cheap hosting (object cache & OPcache)

Reduce TTFB on Cheap Hosting (Object Cache & OPcache)

Time To First Byte (TTFB) is a critical performance metric for WordPress sites. On cheap hosting, slow TTFB can frustrate visitors and harm SEO. The good news: you can significantly reduce TTFB by enabling OPcache and object caching, cleaning up your database, and using a CDN. This guide walks you through practical steps to speed up your WordPress site without expensive hosting upgrades.

Quick Fix

  1. Enable PHP OPcache on your server.
  2. Activate an object caching plugin like Redis or Memcached.
  3. Clean up your WordPress database to remove overhead.
  4. Integrate a CDN to serve static assets closer to users.

Why This Happens

Cheap hosting often uses shared resources and limited server configurations, resulting in slower PHP execution and database queries. Without caching, every page load triggers PHP scripts and database calls from scratch, increasing TTFB. OPcache stores precompiled PHP bytecode in memory, reducing script load times. Object caching stores database query results in memory, cutting down repeated queries. Cleaning the database removes bloat that slows queries. A CDN reduces latency by serving assets from edge servers near visitors.

Step-by-step

1. Enable OPcache

OPcache is a PHP extension that caches compiled script bytecode. Many cheap hosts support it but may not enable it by default.

  1. Check if OPcache is enabled by creating a phpinfo.php file in your WordPress root with this content:
    <?php
    phpinfo();
    ?>
  2. Access yourdomain.com/phpinfo.php and search for “OPcache”. If enabled, you’ll see its configuration.
  3. If not enabled, enable it via your hosting control panel or by adding this to your php.ini or .user.ini file:
    opcache.enable=1
    opcache.memory_consumption=128
    opcache.interned_strings_buffer=8
    opcache.max_accelerated_files=4000
    opcache.revalidate_freq=60
    opcache.fast_shutdown=1
  4. Restart PHP or your web server if possible.

2. Enable Object Cache

Object caching stores database query results in memory, reducing repeated queries and lowering TTFB.

  1. Check if your host supports Redis or Memcached. You can ask support or check documentation.
  2. Install a WordPress plugin for object caching, for example:
    • Redis: Redis Object Cache plugin
    • Memcached: Memcached Redux or W3 Total Cache
  3. Configure the plugin to connect to your Redis or Memcached server. Usually, this is 127.0.0.1 and default ports.
  4. Verify caching is active via the plugin’s status page.

3. Clean Up Your Database

A bloated database slows queries, increasing TTFB. Cleaning removes overhead, spam, revisions, and transient options.

  1. Backup your database before making changes.
  2. Install a plugin like WP-Optimize or Advanced Database Cleaner.
  3. Run database optimization:
    • Remove post revisions
    • Delete spam and trashed comments
    • Clear expired transients
    • Optimize database tables
  4. Schedule regular cleanups to maintain performance.

4. Use a CDN

A Content Delivery Network (CDN) reduces latency by serving static files (images, CSS, JS) from servers closer to visitors.

  1. Choose a CDN provider (Cloudflare, BunnyCDN, StackPath, etc.).
  2. Create an account and configure your domain.
  3. Change your DNS nameservers to point to the CDN (if using Cloudflare) or configure your CDN to pull from your origin server.
  4. Install a plugin like Cloudflare or CDN Enabler to integrate the CDN with WordPress.
  5. Verify static assets load from the CDN URL.

Works on

Environment Notes
Apache Supports OPcache and object cache; .htaccess may be used for CDN rewrites.
Nginx Fully compatible with OPcache and object cache; CDN integration via proxy or DNS.
LiteSpeed Supports OPcache and object cache; LiteSpeed Cache plugin can help.
cPanel Enable OPcache via MultiPHP INI Editor; Redis/Memcached often available.
Plesk Enable OPcache via PHP settings; Redis/Memcached extensions can be installed.

FAQ

Q: How do I know if OPcache is working?
A: Use a phpinfo() page or a plugin like Query Monitor to check if OPcache is enabled and caching scripts.
Q: Can I enable object caching without Redis or Memcached?
A: Yes, but it’s less efficient. Some plugins offer file-based caching, but memory-based caches like Redis/Memcached are faster.
Q: Will enabling OPcache and object cache fix all performance issues?
A: They significantly reduce TTFB but don’t replace good hosting or optimized themes/plugins. Combine with database cleanup and CDN for best results.
Q: Is it safe to clean my database with plugins?
A: Yes, if you backup first. Use reputable plugins and avoid deleting data you might need.
Q: Does using a CDN increase my hosting costs?
A: Most CDNs have free tiers or low-cost plans. They
…
Speed & Security

Recent Posts

  • Top WordPress Themes for Blogs in 2025
  • WordPress Admin Panel Trick: Adding ID Field to the Posts Listing
  • Solution previous_posts_link and next_posts_link Not Working
  • Show Top Commentators in WordPress Without a Plugin
  • How to Style Admin Comments in WordPress

Recent Comments

    Archives

    • August 2025

    Categories

    • Admin & Blocks
    • Admin & UI
    • Automation
    • Automation & Plugins
    • Comments
    • Comparisons
    • Database & Revisions
    • Developer Snippets
    • Fixes & Errors
    • Media & Thumbnails
    • Queries & Pagination
    • Security
    • Speed & Security
    • Tips & Tricks
    • WooCommerce How‑tos
    • WordPress Snippets
    • WordPress Themes
    • Terms & Conditions
    • Affiliate Disclosure

    Copyright © 2025 wpcanyon.com.

    Powered by PressBook WordPress theme

    Also by the maker of MySurveyReviews.com