Codeigniter-将视图缓存到视图中 [英] Codeigniter- cache view into a view

查看:59
本文介绍了Codeigniter-将视图缓存到视图中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

i'm wondering if it's possible to cache a view which is loaded inside another view.

我这样做:

view.php:

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

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

so view.php requires a new view inside himself, can i cache the views/modules/new_view.php content?

推荐答案

Codeigniter具有 网页缓存

Codeigniter has Web Page Caching


CodeIgniter允许您缓存页面以实现最大的
性能。

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

虽然CodeIgniter的速度非常快,但是您在页面中显示的动态信息
的数量将直接与服务器
的资源,内存和处理周期相关,这会影响
页面的加载速度。通过缓存页面,由于它们以完全渲染的状态保存,因此可以获得接近
静态网页的性能。

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 是您希望页面在刷新之间保持高速缓存的分钟数。您可以将其放置在函数中的任何位置。

To do it you would use the code below where n is the number of minutes you wish the page to remain cached between refreshes. You can place it anywhere within a function.

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

更新

要仅缓存页面的一部分或仅一个视图,可以使用 CodeIgniter-缓存

To cache just a portion of the page, or just a single view, you can use CodeIgniter-Cache.


CodeIgniter-Cache是​​CodeIgniter的部分缓存库。
允许您在文件系统中写入数据或从中获取数据。
通过以序列化形式在
文件系统上存储复杂或大块数据,您可以减轻数据库的压力,也可以简单地缓存
Twitter调用。

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缓存 :简单,灵活的缓存部分代码

MP Cache: Simple flexible Caching of parts of code

这篇关于Codeigniter-将视图缓存到视图中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆