Re: Smarter caching needed
| From: | Konstantin A. Pelepelin | Date: | Mon, 30 Jun 2003 10:32:28 +0000 |
| Subject: | Re: Smarter caching needed | ||
| References: | 1 2 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-1707@lists.php.net to get a copy of this message | ||
On Fri, 27 Jun 2003 11:40:07 -0600, Tom Anderson <toma@etree.org> wrote:
The front page has some very complicated queries on it which can take a bit of time to complete, especially _if multiple people request the page between the time the cache has expired and a new copy is put in place_.I can suggest a quick workaround. Set $smarty->caching to 1, calculate $cache_lifetime=base_cache_lifetime; if(rand(0,99)) $cache_lifetime+=60; Then you will have only one request per hundred that will check for base cache lifetime, other 99 requests will check for lifetime plus 1 minute, so there is a little chance that two requests will regenerate cache at the same time. Adjust numbers as you like. To developers: I have another question about caching. I have a page with long list of search results. Each element of list changes very rare, but the whole page is the result of user's request, so the set of elements changes every time and there is small chance to have cache hit. Or a page consists of parts with different mean update time. I'd like to cache individual elements, and do it with custom function, something like {cacheable_include file="..." cache_group="elements_$id" cache_lifetime=68400 [parameters...]} The question is: can I use $smarty object passed to smarty_function_cacheable_include() for $smarty->fetch() in that function, or my modified caching parameters will interfere with old parameters and I should create new Smarty object for each include (or save/restore some internal vars)? Konstantin A. Pelepelin