Yii 是否缓存外部 javascript 文件和 CSS 文件?

发布于 2024-12-11 10:35:43 字数 171 浏览 0 评论 0 原文

Yii 是否缓存外部 javascript 文件和 CSS 文件?

我想使用 Yii 缓存来缓存我的主页。 我的主页文件非常小(不包括js和css)。我的数据库中的缓存大小为 5.7K。

我想知道 Yii 是否缓存外部 js 和 css 文件?

我确实认为它不会缓存外部图像文件。

Does Yii Cache external javascript files and CSS files?

I want to cache my home page using Yii cache.
The file size of my home page is quite small(excluding js and css). The cached size is 5.7K in my database.

I am wondering whether Yii cache external js and css files?

I do think It does not cache external images files.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情愿 2024-12-18 10:35:43

Yii 可以几种不同的方式缓存它生成的动态内容 将其存储为静态内容,包括缓存 数据库结果页面片段等任何东西从数据库查询并由 PHP 动态转换为 HTML 文档可以由框架缓存。

CSS、JS 和图像(通常)已经是静态内容,框架不会生成这些内容,因此无法缓存它们。

静态内容主要缓存在客户端的 Web 浏览器中,或快速分布式内容交付中(CDN) 服务器。

也就是说,Yii 可以做一些事情来帮助加速 CSS 和 JS:

Yii 的 CAssetManager< /a> 允许您使用 Yii 压缩静态脚本(使用第 3 方工具),然后“缓存”优化后的脚本(在 assets 文件夹中)。这也可以通过服务器脚本和扩展来完成。

您还可以指定不同的缓存后端,例如 Memcached和 APC,Yii 将存储它缓存的 HTML,但这不会直接影响您的图像和 CSS/JS。

Yii can cache the dynamic content it generates a couple of different ways by storing it as static content, including caching database results, page fragments, etc. Anything queried from the database and dynamically turned into an HTML document by PHP can be cached by the framework.

CSS, JS and Images are (usually) already static content, which the framework is not generating, so it cannot cache it.

Static content is mostly cached in the client's web browser, or on fast distributed content delivery (CDN) servers.

That said, Yii can do a few things to help speed up CSS and JS:

Yii's CAssetManager allows you to use Yii to compress your static scripts (using 3rd party tools) and then "cache" the optimized scripts (in the assets folder). This can also be done with server scripts and extensions.

You can also specify different cache backends, like Memcached and APC, where Yii will store the HTML it caches, but again that does not directly affect your images and CSS/JS.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文