gpt4 book ai didi

php - Codeigniter-将 View 缓存成 View

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:38:49 26 4
gpt4 key购买 nike

我想知道是否可以缓存在另一个 View 中加载的 View 。

我愿意:

view.php:

<div>
<?php echo $this->load->view('modules/new_view'); ?>
</div>

所以 view.php 内部需要一个新 View ,我可以缓存 views/modules/new_view.php 内容吗?

最佳答案

Codeigniter 有 Web Page Caching

CodeIgniter lets you cache your pages in order to achieve maximum performance.

Although CodeIgniter is quite fast, the amount of dynamic information you display in your pages will correlate directly to the server resources, memory, and processing cycles utilized, which affect your page load speeds. By caching your pages, since they are saved in their fully rendered state, you can achieve performance that nears that of static web pages.

要做到这一点,您可以使用下面的代码,其中 n 是您希望页面在两次刷新之间保持缓存的分钟数。您可以将它放在函数中的任何位置。

$this->output->cache(n);

更新

要仅缓存页面的一部分或单个 View ,您可以使用 CodeIgniter-Cache .

CodeIgniter-Cache is a partial caching library for CodeIgniter. It allows you to write and get chunks of data to and from the filesystem. By storing complex or large chunks of data in serialized form on the file system you can relieve stress from the database or simply cache Twitter calls.

另一种选择

MP Cache : 简单灵活的部分代码缓存

关于php - Codeigniter-将 View 缓存成 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18192259/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com