Evan Lee
Evan Lee

Reputation: 758

Does Yii Cache external javascript files and CSS files?

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.

Upvotes: 2

Views: 3023

Answers (1)

thaddeusmt
thaddeusmt

Reputation: 15600

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.

Upvotes: 4

Related Questions