If you run the WordPress site and want the performance of websites faster but do not want to use plugins, this guide for you.

We will show you how to activate the full page caching using define('WP_CACHE', true); and several lines of code. There is no plugin, not bloated – only clean and simple optimization.

What happened define('WP_CACHE', true); Do?

This line tells WordPress to activate caching support. It is looking for a file called advanced-cache.php in wp-content/ directory.

If you find the file, it will try to serve the content that is -Cache before loading the entire WordPress machine.

Why WordPress won’t cache automatically

Add WP_CACHE Don’t save your site by itself. You need to make logic to save and present the -Cache files. Usually, the plugin handles this. But you can do it yourself with a few lines of code.

Step 1: Create your cache file

In the wp-content/Create a called file advanced-cache.php. Paste the following code:

<?php
$cache_key = md5($_SERVER['REQUEST_URI']);
$cache_file = __DIR__ . '/cache/' . $cache_key . '.html';

if (file_exists($cache_file) && (filemtime($cache_file) > (time() - 3600))) {
    readfile($cache_file);
    exit;
}

ob_start();

This code checks whether there are files that are -Cache and fresh. If so, it presents it and skips WordPress.

Step 2: Save the output to the cache

At the end of you footer.php file or right afterwards wp_footer()add:

<?php
if (defined('WP_CACHE') && WP_CACHE) {
    $cache_key = md5($_SERVER['REQUEST_URI']);
    $cache_file = WP_CONTENT_DIR . '/cache/' . $cache_key . '.html';
    file_put_contents($cache_file, ob_get_contents());
}
ob_end_flush();
?>

This stores a full page as an HTML file so that it can be published next time without running WordPress.

Step 3: Create a cache directory

In most cases, cache folder in it wp-content/ It needs to be made manually, but your server’s theme or environment produces it automatically.

Create a folder in it wp-content/ named cache. Give a written permit (usually 755 or 775).

Step 4: Set the cache rules

To avoid caching for users who enter or certain pages, you can extend logic. For example:

if (is_user_logged_in()) return;

This helps avoid problems with special content of users such as carts or dashboards.

Step 5: Your Cache Test

Open your site in disguise mode. See the source and refresh twice. You will see a faster burden time on repeated visits.

Bonus tips (without plugins)

  • Use .htaccess To add a cache header browser.
  • Activate GZIP compression through the server or .htaccess.
  • Optimize images manually or use webp.

Last thought

This method functions well for blogs, direction pages, or simple business sites. If your site is dynamic, consider redis or smart cancellation system.

With only a few code lines, your WordPress site can be faster – no need for plugins!

Reference:

We provide various WordPress speed optimization services. Don’t hesitate to contact us and also explore various exclusive Woocommerce WordPress WordPress plugins.

!! have a nice day !!



Game Center

Game News

Review Film
Rumus Matematika
Anime Batch
Berita Terkini
Berita Terkini
Berita Terkini
Berita Terkini
review anime

Gaming Center

Kiriman serupa