Welcome Guest, Not a member yet? Register   Sign In
question about cache
#1

[eluser]dkf_aimar[/eluser]
Hi,

I am a new fan of CI. However, I am already move from PHP to Groovy/Grails, but I still want to say CI is a great framework that I have met.

After I look through the guide, and there are couple of questions in my mind. Could someone give me some ideas?

1. I have used Smarty before, and I think it is a heavy template engine. But, the reason I have to use it is because of its cache feature. As I known, Smarty can cache partial of page, such as header or footer. Also, If there is a news display page, Smarty is able to cache those pages based on the news ID from a single template, which is very useful. I want to know does CI have the same functionality? Moreover, for some reason, once the caching entry be created, and the detail of news will never be changed, Smarty will keep this entry forever, until you run clear_all_cache(), or manually delete. Can I set the cache entry in CI will never be expired?

2. Currently, I am going to do a task including front-end and back-end. If I give the same name of view for front-end and back-end, and enable cache, does those two view have a conflict with the caching entry? If so, how can I use different folders to store those caching entries? One folder for front-end cache, another one for back-end cache.

3. A simple example, in order to display 1000 news (from MySQL DB) on a page, what difference of performance between CI and CI+Smarty?


Thanks
Aimar
#2

[eluser]jedd[/eluser]
Hi dkf_aimar, and welcome to the CI forums.

Quote:1. I have used Smarty before, and I think it is a heavy template engine. But, the reason I have to use it is because of its cache feature. As I known, Smarty can cache partial of page, such as header or footer. Also, If there is a news display page, Smarty is able to cache those pages based on the news ID from a single template, which is very useful. I want to know does CI have the same functionality? Moreover, for some reason, once the caching entry be created, and the detail of news will never be changed, Smarty will keep this entry forever, until you run clear_all_cache(), or manually delete. Can I set the cache entry in CI will never be expired?

I'd suggest you read through the documentation on caching. Specifically the [url="http://ellislab.com/codeigniter/user-guide/general/caching.html"]general caching overview[/url] but there's also plenty of [url="http://www.google.com/search?as_sitesearch=ellislab.com/codeigniter/user-guide/&q=cache&sa=Go"]other references to cache[/url] features within the CI user manual.

Never-expiring cache is an interesting thing. A casual glance at the manual suggests you can not do this -though perhaps it is possible. A sufficiently large value for n when setting $this->output->cache(n); might be satisfactory.

It seems to me that if your application's performance relies on not re-generating a cached page every several hours .. you have other, larger concerns than cache algorithms.


Quote:2. Currently, I am going to do a task including front-end and back-end. If I give the same name of view for front-end and back-end, and enable cache, does those two view have a conflict with the caching entry? If so, how can I use different folders to store those caching entries? One folder for front-end cache, another one for back-end cache.

I think back and front are vying for most overloaded terms within IT.

What do you mean by back and front?

Caching works by page, rather than by view - though it relies on the usage of views to function - so my interpretation is that separate pages, utilising the same view snippets, would be cached predictably and sanely.

It wouldn't take much effort to test this, though, if you want to clarify and confirm.

Quote:3. A simple example, in order to display 1000 news (from MySQL DB) on a page, what difference of performance between CI and CI+Smarty?

I'm a big fan of metric, but I do not know this unit - '1000 news'. Wink

This question is so reliant on your database structure, the code that wraps around it, the browser's ability to render 1,000 of anything, and a dozen other factors. Really, in this case you're going to have to benchmark it for yourself.
#3

[eluser]dkf_aimar[/eluser]
First of all, thanks for your reply.

Quote:
Quote:1. I have used Smarty before, and I think it is a heavy template engine. But, the reason I have to use it is because of its cache feature. As I known, Smarty can cache partial of page, such as header or footer. Also, If there is a news display page, Smarty is able to cache those pages based on the news ID from a single template, which is very useful. I want to know does CI have the same functionality? Moreover, for some reason, once the caching entry be created, and the detail of news will never be changed, Smarty will keep this entry forever, until you run clear_all_cache(), or manually delete. Can I set the cache entry in CI will never be expired?

I'd suggest you read through the documentation on caching. Specifically the [url="http://ellislab.com/codeigniter/user-guide/general/caching.html"]general caching overview[/url] but there's also plenty of [url="http://www.google.com/search?as_sitesearch=ellislab.com/codeigniter/user-guide/&q=cache&sa=Go"]other references to cache[/url] features within the CI user manual.

Never-expiring cache is an interesting thing. A casual glance at the manual suggests you can not do this -though perhaps it is possible. A sufficiently large value for n when setting $this->output->cache(n); might be satisfactory.

It seems to me that if your application's performance relies on not re-generating a cached page every several hours .. you have other, larger concerns than cache algorithms.

Yes. For a news publisher, the news content would not be changed very often once it be published. For example, a normal news displaying page, we can simply separate it into four pieces: header, content, feedback, and footer. Thus, I will suppose I can cache header, content, and footer in the neven-expiring cache respectively, so only feedback need to be re-generated every hour. It maybe have a better performance (I think). Any objects?


Quote:
Quote:2. Currently, I am going to do a task including front-end and back-end. If I give the same name of view for front-end and back-end, and enable cache, does those two view have a conflict with the caching entry? If so, how can I use different folders to store those caching entries? One folder for front-end cache, another one for back-end cache.

I think back and front are vying for most overloaded terms within IT.

What do you mean by back and front?

Caching works by page, rather than by view - though it relies on the usage of views to function - so my interpretation is that separate pages, utilising the same view snippets, would be cached predictably and sanely.

It wouldn't take much effort to test this, though, if you want to clarify and confirm.


Actually, this is not a big problem. Normally, I will implement a template of CMS for back-end user to load all contents, and a default template for front-end users to view. If I store them into "admin" and "default" folder separately, does CI generate all caching entries into the same folder or not?


Quote:
Quote:3. A simple example, in order to display 1000 news (from MySQL DB) on a page, what difference of performance between CI and CI+Smarty?

I'm a big fan of metric, but I do not know this unit - '1000 news'. Wink

This question is so reliant on your database structure, the code that wraps around it, the browser's ability to render 1,000 of anything, and a dozen other factors. Really, in this case you're going to have to benchmark it for yourself.

Sorry to confuse you. I do not know how to describe this unit. Basically, I just want to know what difference of performance between using CI and CI+Smarty? Are you agree that integration of CI and Smarty can enhance the application performance?

Thanks
Aimar
#4

[eluser]oddman[/eluser]
I wouldn't be using smarty, period. It is an incredibly heavy-handed templating engine that simply isn't required. If you want to use specific caching rather than page-caching, look into using memcache, along with PHP library of sorts to cache results.etc. for a limited amount of time.




Theme © iAndrew 2016 - Forum software by © MyBB