Current Location: Home> Latest Articles> In-Depth Analysis of PHPcms Category Cache Storage Path and Optimization Methods

In-Depth Analysis of PHPcms Category Cache Storage Path and Optimization Methods

M66 2025-07-26

What Is Category Cache

Category cache refers to generating static files of website category content and storing them in a specified path. When users visit the category, the system reads the static files directly instead of generating pages dynamically, significantly improving access speed, reducing server load, and enhancing user experience.

Category Cache Storage Path

In the PHPcms system, the category cache is usually stored in the /data/cache/columns/ directory under the root directory of the website. Each category corresponds to a folder named after the category's English identifier for easy management and access.

How to Configure Category Cache Path

Log into the backend management system, navigate to “System” -> “Core Settings” -> “Website Settings”. In the “URL Settings” section, find “URL Rules”. Enable the “Enable Category Cache” option and set the “Category Cache Directory” to /data/cache/columns/. Save the settings to apply.

Generating Category Cache

Category cache can be generated manually or automatically. Manual generation is available in the backend under “Update Cache” by selecting “Update Category Cache” and clicking the update button. Automatic generation can be set up through scheduled tasks to keep the cache updated.

Code Example

The following example demonstrates how to manually generate the cache for a specified category via code:

<?php
defined('IN_PHPCMS') or exit('No permission resources.');

$catid = 1; // The ID of the category to generate cache for
$allowupdate = 1; // Permission to update cache

if ($allowupdate) {
    pc_base::load_app_class('html', 'content');
    $html = new html();
    $html->category($catid); // Generate category cache
    echo 'Category cache generated successfully!';
} else {
    echo 'Cache update not allowed!';
}
?>

Conclusion

Category caching is a key mechanism in PHPcms for improving website performance. By caching category content as static files, page response speed is increased and server pressure is reduced. This article covered the cache storage path, configuration, and generation methods to provide developers with useful guidance for maintaining stable and efficient websites.