🚀 Is building a website too difficult? Let me guide you step by step—Learn about the 「Naibabiji WordPress Website Building Coaching Service」 →

How to generate HTML cache files for your WordPress website without using plugins

After building your own website, if the loading speed is slow, we can add a caching function to the website. The most common method to add cache to a WordPress website is to install caching Plugins, such asWP Super CacheWP Rocketthese. Today, I'll share another method that directly uses PHP to generate HTML cache. This method directly uses PHP to generate HTML on the server. When a user visits, it checks if the MD5 has changed. If not, it directly sends the HTML file to the user, avoiding regeneration on the server.

Method for PHP to Generate WordPress Cache Files

1. Copy the code below and save it as a cache.php file.
CACHE_LIFE){   
               unlink($file);   
           }   
        }   
    }   
    ob_start('auto_cache');                 //回调函数 auto_cache   
}   
else{   
    if(file_exists($cache_file)){           //file_exists() 函数检查文件或目录是否存在。   
        unlink($cache_file);                //不是GET的请求就删除缓存文件。   
    }   
}   
?>
2. Upload the cache.php file to the website root directory. 3. Create a cache folder in the website root directory and give it 777 permissions. 4. Modify the index.php file in the website root directory, and inserton the next line.
require('cache.php');
缓存文件Note: Naiba has not actually tested the feasibility of this method and does not recommend novice friends to use this method. Beginners are advised to use the Plugin method to generate cache files for WordPress websites, such as the following:
  1. WordPress Caching Plugin WP Rocket 3.4.3 Usage Tutorial and Download Address
  2. WordPress Caching Plugin WP Super Cache Download and Setup Tutorial
  3. Simple WordPress caching plugin: Breeze
  4. #WebsiteBuilding# Configuring Nginx fastcgi_cache to Cache and Accelerate WordPress Websites

🚀 Still feeling confused after reading the tutorial? Let me guide you step-by-step instead.

「Naibabiji WordPress Website Building Coaching」 — From selecting a domain and purchasing hosting to installing themes and publishing posts, I「ll guide you through every step, helping you avoid detours and reach your goals directly.

👉 Learn about Website Building Coaching Service
🔒

Comments are closed

The comment function for this article is closed. If you have any questions, please feel free to contact us through other channels.

×
二维码

Scan to Follow