pavlikm / cache-html-part
此包最新版本(1.0.1)没有可用的许可信息。
在浏览器中缓存HTML部分
1.0.1
2021-03-16 15:45 UTC
This package is auto-updated.
Last update: 2024-09-16 23:19:28 UTC
README
cache-html-part 是一个简单的库,可以将页面上的任何静态内容“存储”在客户端浏览器中,因此对同一页面(或具有相同静态元素的另一个页面)的其他请求将消耗更少的数据,并且渲染速度更快。
cache-html-part 通过缓存一些渲染的HTML部分来节省带宽并降低加载速度。
安装
composer require pavlikm/cache-html-part
使用
在PHP中使用cache-html-part
use pavlikm\CacheHtmlPart; <?= CacheHtmlPart::render($yourGeneratedHtml); ?>
并用HTML注释 <!-- static -->
和 <!-- static-end -->
标记页面的任何静态部分
<html> <head></head> <body> <div>This div will be transfered from server again and again and again... even if is still the same...</div> <!-- static --> <div>But this div will be transfered only once! Next time browser will render it by self.</div> <!-- static-end --> </body> </html>
cache-html-part和SEO
cache-html-part 不会影响任何SEO爬虫。它使用对爬虫“不可见”的HTML注释。