mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
342 lines
11 KiB
HTML
342 lines
11 KiB
HTML
|
|
|
|
<!DOCTYPE html>
|
|
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
|
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>Web Page Caching — CodeIgniter4 4.0.0-alpha.2 documentation</title>
|
|
|
|
|
|
|
|
|
|
<link rel="shortcut icon" href="../_static/ci-icon.ico"/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" />
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="top" title="CodeIgniter4 4.0.0-alpha.2 documentation" href="../index.html"/>
|
|
<link rel="up" title="General Topics" href="index.html"/>
|
|
<link rel="next" title="Code Modules" href="modules.html"/>
|
|
<link rel="prev" title="Error Handling" href="errors.html"/>
|
|
|
|
|
|
<script src="../_static/js/modernizr.min.js"></script>
|
|
|
|
</head>
|
|
|
|
<body class="wy-body-for-nav" role="document">
|
|
|
|
|
|
<div class="wy-grid-for-nav">
|
|
|
|
|
|
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
|
<div class="wy-side-scroll">
|
|
<div class="wy-side-nav-search">
|
|
|
|
|
|
|
|
<a href="../index.html" class="icon icon-home"> CodeIgniter4
|
|
|
|
|
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
<div role="search">
|
|
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
|
|
<input type="text" name="q" placeholder="Search docs" />
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
<input type="hidden" name="area" value="default" />
|
|
</form>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../intro/index.html">Welcome to CodeIgniter4</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../concepts/index.html">CodeIgniter4 Overview</a></li>
|
|
</ul>
|
|
<ul class="current">
|
|
<li class="toctree-l1 current"><a class="reference internal" href="index.html">General Topics</a><ul class="current">
|
|
<li class="toctree-l2"><a class="reference internal" href="configuration.html">Working With Configuration Files</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="urls.html">CodeIgniter URLs</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="helpers.html">Helper Functions</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="common_functions.html">Global Functions and Constants</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="logging.html">Logging Information</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="errors.html">Error Handling</a></li>
|
|
<li class="toctree-l2 current"><a class="current reference internal" href="#">Web Page Caching</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="modules.html">Code Modules</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="managing_apps.html">Managing your Applications</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="environments.html">Handling Multiple Environments</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../incoming/index.html">Controllers and Routing</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../outgoing/index.html">Building Responses</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Working With Databases</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../models/index.html">Modeling Data</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../dbmgmt/index.html">Managing Databases</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../libraries/index.html">Library Reference</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../testing/index.html">Testing</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../cli/index.html">Command Line Usage</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../extending/index.html">Extending CodeIgniter</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../license.html">The MIT License (MIT)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="../changelogs/index.html">Change Logs</a></li>
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
|
|
|
|
|
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
|
|
|
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
|
<a href="../index.html">CodeIgniter4</a>
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
<div class="wy-nav-content">
|
|
<div class="rst-content">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div role="navigation" aria-label="breadcrumbs navigation">
|
|
|
|
<ul class="wy-breadcrumbs">
|
|
|
|
<li><a href="../index.html">Docs</a> »</li>
|
|
|
|
<li><a href="index.html">General Topics</a> »</li>
|
|
|
|
<li>Web Page Caching</li>
|
|
|
|
|
|
<li class="wy-breadcrumbs-aside">
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
<hr/>
|
|
</div>
|
|
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
|
<div itemprop="articleBody">
|
|
|
|
<div class="section" id="web-page-caching">
|
|
<h1>Web Page Caching<a class="headerlink" href="#web-page-caching" title="Permalink to this headline">¶</a></h1>
|
|
<p>CodeIgniter lets you cache your pages in order to achieve maximum
|
|
performance.</p>
|
|
<p>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 much closer to that of
|
|
static web pages.</p>
|
|
<div class="section" id="how-does-caching-work">
|
|
<h2>How Does Caching Work?<a class="headerlink" href="#how-does-caching-work" title="Permalink to this headline">¶</a></h2>
|
|
<p>Caching can be enabled on a per-page basis, and you can set the length
|
|
of time that a page should remain cached before being refreshed. When a
|
|
page is loaded for the first time, the file will be cached using the
|
|
currently configured cache engine. On subsequent page loads the cache file
|
|
will be retrieved and sent to the requesting user’s browser. If it has
|
|
expired, it will be deleted and refreshed before being sent to the
|
|
browser.</p>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">The Benchmark tag is not cached so you can still view your page
|
|
load speed when caching is enabled.</p>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="enabling-caching">
|
|
<h2>Enabling Caching<a class="headerlink" href="#enabling-caching" title="Permalink to this headline">¶</a></h2>
|
|
<p>To enable caching, put the following tag in any of your controller
|
|
methods:</p>
|
|
<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">cachePage</span><span class="p">(</span><span class="nv">$n</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>Where <code class="docutils literal"><span class="pre">$n</span></code> is the number of <strong>seconds</strong> you wish the page to remain
|
|
cached between refreshes.</p>
|
|
<p>The above tag can go anywhere within a method. It is not affected by
|
|
the order that it appears, so place it wherever it seems most logical to
|
|
you. Once the tag is in place, your pages will begin being cached.</p>
|
|
<div class="admonition important">
|
|
<p class="first admonition-title">Important</p>
|
|
<p class="last">If you change configuration options that might affect
|
|
your output, you have to manually delete your cache files.</p>
|
|
</div>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">Before the cache files can be written you must set the cache
|
|
engine up by editing <strong>application/Config/Cache.php</strong>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="deleting-caches">
|
|
<h2>Deleting Caches<a class="headerlink" href="#deleting-caches" title="Permalink to this headline">¶</a></h2>
|
|
<p>If you no longer wish to cache a file you can remove the caching tag and
|
|
it will no longer be refreshed when it expires.</p>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">Removing the tag will not delete the cache immediately. It will
|
|
have to expire normally.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
<div class="articleComments">
|
|
|
|
</div>
|
|
</div>
|
|
<footer>
|
|
|
|
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
|
|
|
<a href="modules.html" class="btn btn-neutral float-right" title="Code Modules" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
|
|
|
|
|
|
<a href="errors.html" class="btn btn-neutral" title="Error Handling" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
|
|
|
</div>
|
|
|
|
|
|
<hr/>
|
|
|
|
<div role="contentinfo">
|
|
<p>
|
|
© Copyright 2014-2018 British Columbia Institute of Technology.
|
|
Last updated on Nov 28, 2018.
|
|
|
|
</p>
|
|
</div>
|
|
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
|
|
|
</footer>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT:'../',
|
|
VERSION:'4.0.0-alpha.2',
|
|
COLLAPSE_INDEX:false,
|
|
FILE_SUFFIX:'.html',
|
|
HAS_SOURCE: false,
|
|
SOURCELINK_SUFFIX: ''
|
|
};
|
|
</script>
|
|
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript" src="../_static/js/theme.js"></script>
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
jQuery(function () {
|
|
SphinxRtdTheme.StickyNav.enable();
|
|
});
|
|
</script>
|
|
|
|
|
|
</body>
|
|
</html> |