实例:实现动态网页的静态缓存_PHP教程
实例:实现动态网页的静态缓存
源动态网页
<ol class="dp-xml"><li class="alt"><span><span class="tag"><</span><span class="tag-name">title</span><span class="tag">></span><span>实例:实现动态网页的静态缓存</span><span class="tag"></</span><span class="tag-name">title</span><span class="tag">></span><span> </span></span></li><li><span><span class="tag"><</span><span class="tag-name">h3</span><span class="tag">></span><span>实例:实现动态网页的静态缓存</span><span class="tag"></</span><span class="tag-name">h3</span><span class="tag">></span><span> </span></span></li><li class="alt"><span><span class="tag"><</span><span class="tag-name">p</span><span class="tag">></span><span> </span></span></li><li><span><span class="tag"><</span><span class="tag-name">chtml</span><span class="tag">></span><span> </span></span></li><li class="alt"><span><span class="tag"><</span><span class="tag-name">for</span><span> </span><span class="attribute">end</span><span>=</span><span class="attribute-value">0</span><span> </span><span class="attribute">start</span><span>=</span><span class="attribute-value">20</span><span class="tag">></span><span> </span></span></li><li><span> <span class="tag"><</span><span class="tag-name">b</span><span class="tag">></span><span>@{int:@{for:getSuffix}+1}-</span><span class="tag"></</span><span class="tag-name">b</span><span class="tag">></span><span> </span></span></li><li class="alt"><span> <span class="tag"><</span><span class="tag-name">forendforend</span><span class="attribute">forendforend</span><span>=@{for:getSuffix}</span><span class="tag">></span><span> </span></span></li><li><span> <span class="tag"><</span><span class="tag-name">fontcolorfontcolor</span><span class="attribute">fontcolorfontcolor</span><span>=</span><span class="attribute-value">red</span><span class="tag">></span><span>@{int:@{for:getSuffix}+1}-</span><span class="tag"></</span><span class="tag-name">font</span><span class="tag">></span><span> </span></span></li><li class="alt"><span> <span class="tag"></</span><span class="tag-name">for</span><span class="tag">></span><span> </span></span></li><li><span> <span class="tag"><</span><span class="tag-name">br</span><span class="tag">></span><span> </span></span></li><li class="alt"><span><span class="tag"></</span><span class="tag-name">for</span><span class="tag">></span><span> </span></span></li><li><span><span class="tag"></</span><span class="tag-name">chtml</span><span class="tag">></span><span> </span></span></li><li class="alt"><span><span class="tag"></</span><span class="tag-name">p</span><span class="tag">></span><span> </span></span></li></ol>
(例子文件:_samples/file_page.html)
读缓存的静态文件信息
<ol class="dp-xml"><li class="alt"><span><span class="tag"><</span><span class="tag-name">file</span><span> </span><span class="attribute">act</span><span>=</span><span class="attribute-value">info</span><span class="tag">></span><span>WEB-INF/cache/page_test.html</span><span class="tag"></</span><span class="tag-name">file</span><span class="tag">></span><span> </span></span></li></ol>
判断静态文件是否存在
<ol class="dp-xml"><li class="alt"><span><span class="tag"><</span><span class="tag-name">if</span><span> </span><span class="attribute">x</span><span>="@{file:exists}"</span><span class="attribute-value">else</span><span>=0</span><span class="tag">></span><span> </span></span></li><li><span> <span class="tag"><</span><span class="tag-name">call</span><span class="tag">></span><span>page</span><span class="tag"></</span><span class="tag-name">call</span><span class="tag">></span><span> </span></span></li><li class="alt"><span> <span class="tag"><</span><span class="tag-name">callxcallx</span><span class="attribute">callxcallx</span><span>=</span><span class="attribute-value">true</span><span class="tag">></span><span>cache</span><span class="tag"></</span><span class="tag-name">call</span><span class="tag">></span><span> </span></span></li><li><span><span class="tag"></</span><span class="tag-name">if</span><span class="tag">></span><span> </span></span></li></ol>
存在就调用cache,不存在则调用page
<ol class="dp-xml"><li class="alt"><span><span class="tag"><</span><span class="tag-name">call</span><span class="tag">></span><span>page</span><span class="tag"></</span><span class="tag-name">call</span><span class="tag">></span><span> </span></span></li><li><span> <span class="tag"><</span><span class="tag-name">call</span><span> </span><span class="attribute">x</span><span>=</span><span class="attribute-value">true</span><span class="tag">></span><span>cache</span><span class="tag"></</span><span class="tag-name">call</span><span class="tag">></span><span> </span></span></li></ol>
可调用标签cache,读缓存文件
<ol class="dp-xml"><li class="alt"><span><span class="tag"><</span><span class="tag-name">chtml</span><span> </span><span class="attribute">onlycallid</span><span>=</span><span class="attribute-value">cache</span><span class="tag">></span><span> </span></span></li><li><span><span class="tag"><</span><span class="tag-name">file</span><span> </span><span class="attribute">act</span><span>=</span><span class="attribute-value">read</span><span> </span><span class="attribute">method</span><span>=</span><span class="attribute-value">str</span><span> </span><span class="attribute">name</span><span>=</span><span class="attribute-value">page</span><span class="tag">></span><span>WEB-INF/cache/page_test.html</span><span class="tag"></</span><span class="tag-name">file</span><span class="tag">></span><span> </span></span></li><li class="alt"><span><span class="tag"></</span><span class="tag-name">chtml</span><span class="tag">></span><span> </span></span></li></ol>
可调用标签page
<ol class="dp-xml"><li class="alt"><span><span class="tag"><</span><span class="tag-name">chtml</span><span> </span><span class="attribute">id</span><span>=</span><span class="attribute-value">page</span><span> </span><span class="attribute">file</span><span>=</span><span class="attribute-value">"@{sys:curPath}file_page.html"</span><span> </span><span class="attribute">save</span><span>=</span><span class="attribute-value">"WEB-INF/cache/page_test.html"</span><span> onlycall </span><span class="tag">/></span><span> </span></span></li></ol>
引入动态网页文件@{sys:curPath}file_page.html,并保存为WEB-INF/cache/page_test.html文件
显示缓存内容
@{file:page}
完整代码
<ol class="dp-xml"><li class="alt"><span><span class="tag"><</span><span class="tag-name">html</span><span class="tag">></span><span> </span></span></li><li><span><span class="tag"><</span><span class="tag-name">chtml</span><span class="tag">></span><span> </span></span></li><li class="alt"><span><span class="tag"><</span><span class="tag-name">file</span><span> </span><span class="attribute">act</span><span>=</span><span class="attribute-value">info</span><span class="tag">></span><span>WEB-INF/cache/page_test.html</span><span class="tag"></</span><span class="tag-name">file</span><span class="tag">></span><span> </span></span></li><li><span><span class="tag"><</span><span class="tag-name">if</span><span> </span><span class="attribute">x</span><span>=</span><span class="attribute-value">"@{file:exists}"</span><span> </span><span class="attribute">else</span><span>=</span><span class="attribute-value">0</span><span class="tag">></span><span> </span></span></li><li class="alt"><span> <span class="tag"><</span><span class="tag-name">call</span><span class="tag">></span><span>page</span><span class="tag"></</span><span class="tag-name">call</span><span class="tag">></span><span> </span></span></li><li><span> <span class="tag"><</span><span class="tag-name">call</span><span> </span><span class="attribute">x</span><span>=</span><span class="attribute-value">true</span><span class="tag">></span><span>cache</span><span class="tag"></</span><span class="tag-name">call</span><span class="tag">></span><span> </span></span></li><li class="alt"><span><span class="tag"></</span><span class="tag-name">if</span><span class="tag">></span><span> </span></span></li><li><span><span class="tag"></</span><span class="tag-name">chtml</span><span class="tag">></span><span> </span></span></li><li class="alt"><span><span class="tag"><</span><span class="tag-name">chtml</span><span> </span><span class="attribute">id</span><span>=</span><span class="attribute-value">page</span><span> </span><span class="attribute">file</span><span>=</span><span class="attribute-value">"@{sys:curPath}file_page.html"</span><span> </span><span class="attribute">save</span><span>=</span><span class="attribute-value">"WEB-INF/cache/page_test.html"</span><span> onlycall </span><span class="tag">/></span><span> </span></span></li><li><span><span class="tag"><</span><span class="tag-name">chtml</span><span> onlycall </span><span class="attribute">id</span><span>=</span><span class="attribute-value">cache</span><span class="tag">></span><span> </span></span></li><li class="alt"><span><span class="tag"><</span><span class="tag-name">file</span><span> </span><span class="attribute">act</span><span>=</span><span class="attribute-value">read</span><span> </span><span class="attribute">method</span><span>=</span><span class="attribute-value">str</span><span> </span><span class="attribute">name</span><span>=</span><span class="attribute-value">page</span><span class="tag">></span><span>WEB-INF/cache/page_test.html</span><span class="tag"></</span><span class="tag-name">file</span><span class="tag">></span><span> </span></span></li><li><span><span class="tag"></</span><span class="tag-name">chtml</span><span class="tag">></span><span>@{file:page} </span></span></li><li class="alt"><span><span class="tag"></</span><span class="tag-name">html</span><span class="tag">></span><span> </span></span></li></ol>
效果
(例子文件:_samples/file_cache.html)
抓紧体验体验吧!


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

Python中的支持向量机(SupportVectorMachine,SVM)是一个强大的有监督学习算法,可以用来解决分类和回归问题。SVM在处理高维度数据和非线性问题的时候表现出色,被广泛地应用于数据挖掘、图像分类、文本分类、生物信息学等领域。在本文中,我们将介绍在Python中使用SVM进行分类的实例。我们将使用scikit-learn库中的SVM模

随着新一代前端框架的不断涌现,VUE3作为一个快速、灵活、易上手的前端框架备受热爱。接下来,我们就来一起学习VUE3的基础知识,制作一个简单的视频播放器。一、安装VUE3首先,我们需要在本地安装VUE3。打开命令行工具,执行以下命令:npminstallvue@next接着,新建一个HTML文件,引入VUE3:<!doctypehtml>

随着互联网的普及,验证码已经成为了登录、注册、找回密码等操作的必要流程。在Gin框架中,实现验证码功能也变得异常简单。本文将介绍如何在Gin框架中使用第三方库实现验证码功能,并提供示例代码供读者参考。一、安装依赖库在使用验证码之前,我们需要安装一个第三方库goCaptcha。安装goCaptcha可以使用goget命令:$goget-ugithub

Golang是一门功能强大且高效的编程语言,可以用于开发各种应用程序和服务。在Golang中,指针是一种非常重要的概念,它可以帮助我们更灵活和高效地操作数据。指针转换是指在不同类型之间进行指针操作的过程,本文将通过具体的实例来学习Golang中指针转换的最佳实践。1.基本概念在Golang中,每个变量都有一个地址,地址就是变量在内存中的位置。

VAE是一种生成模型,全称是VariationalAutoencoder,中文译作变分自编码器。它是一种无监督的学习算法,可以用来生成新的数据,比如图像、音频、文本等。与普通的自编码器相比,VAE更加灵活和强大,能够生成更加复杂和真实的数据。Python是目前使用最广泛的编程语言之一,也是深度学习的主要工具之一。在Python中,有许多优秀的机器学习和深度

Oracle实例数量与数据库性能关系Oracle数据库是业界知名的关系型数据库管理系统之一,广泛应用于企业级的数据存储和管理中。在Oracle数据库中,实例是一个非常重要的概念。实例是指Oracle数据库在内存中的运行环境,每个实例都有独立的内存结构和后台进程,用于处理用户的请求和管理数据库的操作。实例数量对于Oracle数据库的性能和稳定性有着重要的影响。

随着互联网的迅速发展,数据已成为了当今信息时代最为重要的资源之一。而网络爬虫作为一种自动化获取和处理网络数据的技术,正越来越受到人们的关注和应用。本文将介绍如何使用PHP开发一个简单的网络爬虫,并实现自动化获取网络数据的功能。一、网络爬虫概述网络爬虫是一种自动化获取和处理网络资源的技术,其主要工作过程是模拟浏览器行为,自动访问指定的URL地址并提取所

生成对抗网络(GAN,GenerativeAdversarialNetworks)是一种深度学习算法,它通过两个神经网络互相竞争的方式来生成新的数据。GAN被广泛用于图像、音频、文字等领域的生成任务。在本文中,我们将使用Python编写一个GAN算法实例,用于生成手写数字图像。数据集准备我们将使用MNIST数据集作为我们的训练数据集。MNIST数据集包含
