<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh">
	<id>https://arolstar52-zhtest.hf.space/index.php?action=history&amp;feed=atom&amp;title=OPcache</id>
	<title>OPcache - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://arolstar52-zhtest.hf.space/index.php?action=history&amp;feed=atom&amp;title=OPcache"/>
	<link rel="alternate" type="text/html" href="https://arolstar52-zhtest.hf.space/index.php?title=OPcache&amp;action=history"/>
	<updated>2026-06-29T23:35:00Z</updated>
	<subtitle>在这个wiki上该页的修订历史</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://arolstar52-zhtest.hf.space/index.php?title=OPcache&amp;diff=4792675&amp;oldid=prev</id>
		<title>imported&gt;Hamish-bot：​T9：從條目空間頁面中移除:Category:使用创建条目精灵建立的页面</title>
		<link rel="alternate" type="text/html" href="https://arolstar52-zhtest.hf.space/index.php?title=OPcache&amp;diff=4792675&amp;oldid=prev"/>
		<updated>2026-01-03T06:44:13Z</updated>

		<summary type="html">&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/%E6%9C%BA%E5%99%A8%E4%BA%BA/%E7%94%B3%E8%AF%B7/Hamish-bot/9&quot; class=&quot;extiw&quot; title=&quot;wikipedia:机器人/申请/Hamish-bot/9&quot;&gt;T9&lt;/a&gt;：從條目空間頁面中移除&lt;a href=&quot;/wiki/Category:%E4%BD%BF%E7%94%A8%E5%88%9B%E5%BB%BA%E6%9D%A1%E7%9B%AE%E7%B2%BE%E7%81%B5%E5%BB%BA%E7%AB%8B%E7%9A%84%E9%A1%B5%E9%9D%A2&quot; title=&quot;Category:使用创建条目精灵建立的页面&quot;&gt;Category:使用创建条目精灵建立的页面&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{NoteTA|G1=IT|G2=FL}}&lt;br /&gt;
{{Infobox software&lt;br /&gt;
| name                   = OPcache&lt;br /&gt;
| author                 = The PHP Group&lt;br /&gt;
| released               = {{Start date and age|2008}}&lt;br /&gt;
| programming language   = [[C语言|C]]&lt;br /&gt;
| genre                  = PHP 扩展程序&lt;br /&gt;
| license                = [[PHP许可证]]3.01&lt;br /&gt;
| website                = [https://php.net/manual/extension.opcache.php OPcache手册主页]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;OPcache&amp;#039;&amp;#039;&amp;#039;是一个[[PHP]]扩展程序，由PHP官方发布&amp;lt;ref&amp;gt;{{cite web |author1=PHP手册编辑团队 |title=PHP: OPcache - Manual |url=https://www.php.net/manual/zh/book.opcache.php |website=PHP官方网站 |accessdate=2025-10-28 |language=zh}}&amp;lt;/ref&amp;gt;，其功能是缓存编译后的[[字节码]]以供后续使用&amp;lt;ref name=&amp;quot;book1&amp;quot;&amp;gt;{{cite book |last1=Ajzele |first1=Branko |title=Mastering PHP 7: design, configure, build, and test professional web appilcations in PHP 7 |publisher=Packt Publishing |location=Birmingham, UK |isbn=9781785889943 |page=196 |url=https://www.google.com.sg/books/edition/Mastering_PHP_7/Ing5DwAAQBAJ |accessdate=2025-12-06}}&amp;lt;/ref&amp;gt;，可提升程序的处理速度。&amp;lt;ref name=&amp;quot;webgo&amp;quot;&amp;gt;{{cite web |title=OPCache - Was ist das? |url=https://webgo.de/faq/opcache-was-ist-das |website=WebGo FAQs |language=de |author1=WebGo |accessdate=2025-10-29}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;book2&amp;quot;&amp;gt;{{cite book |author1=Josh Lockhart |title=Modern PHP: New Features and Good Practices |isbn=9781491904992 |url=https://www.google.com.sg/books/edition/Modern_PHP |accessdate=2025-12-06 |language=en |chapter=2}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;veitool&amp;quot;&amp;gt;{{cite web |title=PHP 优化性能之 Opcache 扩展 |url=https://www.veitool.com/news/id/9.html |website=VEITOOL |publisher=VEITOOL |accessdate=2025-11-01 |language=zh-CN |date=2024-09-13}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 历史 ==&lt;br /&gt;
2008年，OPcache的前身，PHPNG的开发已经开始&amp;lt;ref name=&amp;quot;opcqr&amp;quot;&amp;gt;{{cite web |author1=Joe Niland |title=PHP OPcache Quick Reference |url=https://www.sydney.software/blog/php-opcache-quick-reference/ |website=Sydney Blog |accessdate=2025-10-28 |language=en}}&amp;lt;/ref&amp;gt;，到了2013年，PHP团队在新的5.5.0版本将OPcache合并进入PHP核心并被默认启用，这标志着OPcache成为官方且预装扩展&amp;lt;ref name=&amp;quot;intro&amp;quot;&amp;gt;{{cite web |author1=PHP手册编辑团队 |title=PHP: 简介 - Manual |url=https://www.php.net/manual/zh/intro.opcache.php |website=PHP官方网站 |accessdate=2025-10-28 |language=zh}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;opcqr&amp;quot;/&amp;gt;，同时，OPcache在該版本也更新了持久化功能，现在其可将字节码存入[[文件系统]]&amp;lt;ref name=&amp;quot;opcqr&amp;quot;/&amp;gt;，而到了PHP 7.4.0，OPcache则更新了预加载功能，该功能可以预先加载尚未运行的代码以提升性能&amp;lt;ref&amp;gt;{{cite web |author1=PHP手册编辑团队 |title=PHP: 预加载 - Manual |url=https://www.php.net/manual/zh/opcache.preloading.php |website=PHP官方网站 |accessdate=2025-10-28 |language=zh}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;opcqr&amp;quot;/&amp;gt;。到了PHP 8.0.0 时，OPcache添加了一个内建的[[即時編譯|即时编译]]器，原本缓存的操作码本来需要被[[直譯器|解释器]]实时转译为[[机器语言|机器码]]再执行，这次更新使得机器码也可以被缓存，省去了解释的步骤，进一步提升性能&amp;lt;ref&amp;gt;{{cite web |author1=Erik Pöhler |title=Enable, configure and monitor PHPs OPCache - Erik Pöhler&amp;#039;s Weblog |url=https://erikpoehler.com/2021/01/08/enable-configure-and-monitor-phps-opcache/ |website=Erik Pöhler&amp;#039;s Blog |accessdate=2025-10-30 |language=en}}&amp;lt;/ref&amp;gt;，而在最新的PHP 8.4.0中，OPcache的JIT默认获得了64MB的缓冲区空间，但需手工启用&amp;lt;ref&amp;gt;{{cite web |title=PHP 8.4: Opcache: INI 对 JIT 启用方式的更改 {{!}} 日思录 |url=https://www.tubring.cn/articles/php-8_4-opcache-jit-ini-default-changes |website=日思录 |accessdate=2025-11-02 |date=2024-02-29}}{{better source}}&amp;lt;/ref&amp;gt;。&lt;br /&gt;
&lt;br /&gt;
== 原理 ==&lt;br /&gt;
OPcache在访问新代码片段时，會检查其是否存在於缓存。若答案為否，則會编译該段代码，并将编译后生成的字节码在[[随机存储器|内存]]中进行缓存&amp;lt;ref name=&amp;quot;book1&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;intro&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;webgo&amp;quot;/&amp;gt;，下一次执行同一段代码时，便无需运行词法分析等编译过程，将直接从内存中提取字节码进行执行而不是再次编译&amp;lt;ref name=&amp;quot;veitool&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;cloudways&amp;quot;&amp;gt;{{cite web |author1=Shahzeb Ahmed |title=PHP OPcache Explained: How to Improve Your App&amp;#039;s Performance |url=https://www.cloudways.com/blog/integrate-php-opcache/ |website=Cloudways |accessdate=2025-10-30 |date=2018-11-22 |language=en}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web |author1=HiBit |title=Boosting PHP performance with OPCache |url=https://www.hibit.dev/posts/175/boosting-php-performance-with-opcache |website=HiBit Blog |accessdate=2025-10-28 |language=en}}&amp;lt;/ref&amp;gt;或实时编译所有代码&amp;lt;ref name=&amp;quot;webgo&amp;quot;/&amp;gt;。同时，OPcache还会在代码变动时自动更新缓存的字节码&amp;lt;ref&amp;gt;{{cite web |author1=Harish Kumar |title=PHP OPCache: The Secret Weapon for Laravel Performance Boost |url=https://qirolab.com/posts/php-opcache-the-secret-weapon-for-laravel-performance-boost |website=Qirolab |accessdate=2025-10-30 |language=en |date=2024-07-26}}&amp;lt;/ref&amp;gt;。另外，OPcache同样缓存了一些常量及文件中的符号表&amp;lt;ref&amp;gt;{{cite web |title=掌握PHP缓存利器：OPcache与APCu深度解析与优化技巧 - 云原生实践 |url=https://www.oryoy.com/news/zhang-wo-php-huan-cun-li-qi-opcache-yu-apcu-shen-du-jie-xi-yu-you-hua-ji-qiao-a14291483.html |website=云原生实践 |accessdate=2025-11-02 |date=2025-03-04}}{{better source}}&amp;lt;/ref&amp;gt;。&lt;br /&gt;
&lt;br /&gt;
== 实际性能提升 ==&lt;br /&gt;
在PHP 5.5时，OPcache之性能提升约50%，同时降低了[[硬盘|磁盘]]和[[CPU]]的占用率（因为编译过程需要消耗大量CPU&amp;lt;ref name=&amp;quot;veitool&amp;quot;/&amp;gt;）&amp;lt;ref name=&amp;quot;cloudways&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;opcqr&amp;quot;/&amp;gt;，也间接因为性能瓶颈的降低提升了应用程序的可扩展性&amp;lt;ref&amp;gt;{{cite web |author1=LiquidWeb文档作者团队 |title=Zend OpCache for PHP |url=https://www.liquidweb.com/help-docs/performance/website-optimization/zend-opcache-for-php/ |website=Liquid Web |accessdate=2025-10-30 |language=en}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web |author1=Tejas |title=PHP 8+ Performance Tuning for WordPress: OPcache and Beyond - WisdmLabs |url=https://wisdmlabs.com/blog/php-8-performance-tuning-for-wordpress-opcache-and-beyond/ |website=Wisdm Labs|accessdate=2025-10-30 |date=2025-08-13 |language=en}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web |author1=王宏仁 |title=PHP核心開發者告訴你PHP 7的五大效能密技 |url=https://www.ithome.com.tw/news/101602 |website=[[iThome]] |accessdate=2025-11-01 |language=zh-TW |date=2015-12-26}}&amp;lt;/ref&amp;gt;，提升如此显著的原因是操作码被缓存，PHP无需再读取、解析、编译原始码&amp;lt;ref name=&amp;quot;book2&amp;quot;/&amp;gt;。&lt;br /&gt;
&lt;br /&gt;
== 參考資料 ==&lt;br /&gt;
{{Reflist}}&lt;br /&gt;
&lt;br /&gt;
== 外部連結 ==&lt;br /&gt;
{{PHP}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:PHP]]&lt;br /&gt;
[[Category:PHP扩展]]&lt;br /&gt;
&lt;br /&gt;
[[Category:PHP]]&lt;br /&gt;
[[Category:PHP扩展]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Hamish-bot</name></author>
	</entry>
</feed>